Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

adding another column head to cross tab query

Posted on 2014-12-15
22
Medium Priority
?
125 Views
Last Modified: 2014-12-26
i have sales transactions by store / date
i already did cross tab query like this :
TRANSFORM Sum(WeekAvg.DayAvg) AS SumOfDayAvg
SELECT WeekAvg.Store, Sum(WeekAvg.DayAvg) AS [Total Of DayAvg]
FROM WeekAvg
GROUP BY WeekAvg.Store
PIVOT WeekAvg.WekNo;

Open in new window

this will show store as row heading , WeekNumberOf The Year
and sales amount as row values
i woulk like to add also 2 cloumns under the week values to display the firstdayof week and last day of the week
i have the function already , but i want help in adding it to the cross tab query
0
Comment
Question by:NiceMan331
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 5
  • 3
  • +2
22 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40500167
I don't know exactly what you mean, but suspect it cannot be done easily.

In Microsoft Access' crosstab queries, you can only have one Column Heading and one Value option.
0
 

Author Comment

by:NiceMan331
ID: 40500173
ok , in conclusion , my cross tab gives week numbers at comun heading
any other way to select or to display the starting data and ending date of the week number ?
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 40500200
can you provide an example, perhaps an screenshot of what you would like it to look like in Excel?  and maybe some sample data as it is configured in your table.
0
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40500207
I would suggest using some functions in a form, i.e. not part of the query itself, but as Text Boxes.

It would help if you could provide what Dale has asked for, and also what is the start of Week 1 of this year is for your calculations.
0
 

Author Comment

by:NiceMan331
ID: 40500225
here are the data as now  ,
before.png
0
 

Author Comment

by:NiceMan331
ID: 40500231
and here as what i wish to add
After.png
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 40500248
You can't do that in a query.

But you can create a report or form. Insert the week data in the header and the query data in the details section.
Or you can create an empty form and just drag-and-drop the query to create a subform with datasheetview of your data. Then insert the week data in the header.

/gustav
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40500270
The above would make your Week 1 start on Sunday 29 December 2013 - is this correct?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40500313
this is doable, if you will export the crosstab query to excel and manipulate the Excel file using VBA codes.
0
 

Author Comment

by:NiceMan331
ID: 40500749
gustav
But you can create a report or form
may be this is the best solution , but the problem is if i have 52 weeks , i can't image that access report may be fit in one page

philip
The above would make your Week 1 start on Sunday 29 December 2013 - is this correct?
i have no problem about the value of the starting date , the function i use return correct value for me

rey
this is doable, if you will export the crosstab query to excel and manipulate the Excel file using VBA codes.
good suggestion , because i have to do chart in excell based on that query , but i have no experiance in how to make the manipulation in excell
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 40500780
>  the problem is if i have 52 weeks , i can't image that access report may be fit in one page ...

No, it won't. In fact, nothing will. But with a form having the crosstab as a subform, you can scroll horisontally and/or hide columns of little or no interest.

/gustav
0
 

Author Comment

by:NiceMan331
ID: 40500837
but any how i have to export it to excell to do chart analyse
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 40500846
Then you would export the crosstab to Excel, either a worksheet or a Named Range.

Look up the on-line help for:

    DoCmd.OutputTo
    DoCmd.TransferSpreadsheet

/gustav
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40500855
<good suggestion , because i have to do chart in excell based on that query , but i have no experiance in how to make the manipulation in excell >

how much do you know about VBA codes ?
0
 

Author Comment

by:NiceMan331
ID: 40500924
how much do you know about VBA codes ?
i have a lot in VBA for access
but for excell and itc cells , i didn't do it before
0
 

Author Comment

by:NiceMan331
ID: 40516327
rey
i tried to upload the file here but it not accepted
here is sql for query weeklyavg
SELECT Accepted_Trans.Store, Accepted_Trans.WekNo, Sum(Accepted_Trans.Sales_Amt) AS SumOfSales_Amt, Count(Accepted_Trans.Trans_Date) AS CountOfTrans_Date, Sum(Accepted_Trans.Sales_Amt)/Count(Accepted_Trans.Trans_Date) AS DayAvg, First(Accepted_Trans.FrstDayWeek) AS FirstOfFrstDayWeek, Last(Accepted_Trans.LstDayWeek) AS LastOfLstDayWeek
FROM Accepted_Trans
GROUP BY Accepted_Trans.Store, Accepted_Trans.WekNo;

Open in new window

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40516360
@NiceMan

zip the db and upload.
0
 

Author Comment

by:NiceMan331
ID: 40516368
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 40516389
test this
Anal---rev.zip
0
 

Author Comment

by:NiceMan331
ID: 40517340
Excellent
Thanx
by the way , i just have small question in exporting to Excell
what is the code if i want to open a query , select specific data , and copy it to a specific cell in excell
for example if i want in same our example to only copy value of store number 135 where weeks in (5 to 10)
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40517703
just create another query with this statement and save as "myQuery"

TRANSFORM Sum(WeekAvg.DayAvg) AS SumOfDayAvg
SELECT WeekAvg.Store
FROM WeekAvg
WHERE (((WeekAvg.Store)=135))
GROUP BY WeekAvg.Store
PIVOT WeekAvg.WekNo In(5,6,7,8,9,10)

then in the code to export to excel, change

Set rs = CurrentDb.OpenRecordset("WeekAvgByStore")

with

Set rs = CurrentDb.OpenRecordset("myQuery")
0
 

Author Comment

by:NiceMan331
ID: 40518235
ok , thanx rey
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question