I have been trying for the last several days to create a query that will give me all of the values I need to create a report.
Background:
The report is different than anything I have done but I am hoping that for someone out there has. Visually it looks like the following:
Product Name__Week 1__Week 2__Week 3__Week 4__Week 5__BudgetGWP__P riorGWP
Product 1________45____ __56_______0___ ____0_______12_ ______300______ ___250__
Product 2________60____ __66_______0___ ____0_______11_ ______250______ ___225__
Product 3________45____ __56_______0___ ____0_______12_ ______300______ ___225__
Product 4________0_____ __0________0___ ____0_______0__ ______50_______ ___40___
Product 5________45____ __56_______0___ ____0_______12_ ______412______ ___335__
Product 6________0_____ __0________0___ ____0_______0__ ______41_______ ___32___
Etc……All of the values are NOT coming from the same table:
I need to display all products of which in my case there are 22.
I also need to display a column heading called Week 1, 2, 3, ,, when I only have a field called FWeek.
Current State:
Like I said I have been struggling with this type of report. I have been going down the crosstab query road to build a part of this report. I figured out how to use the “In Clause” to create the column headings I needed (Week 1 , 2, 3, ,,), populate zeros where no values were found (Using “Nz” in my sum expression of GWP) but how to get ALL products to list has eluded me. Below is what I have so far on the crosstab query:
[code=vb]
TRANSFORM Nz(Sum(tblStati cAllForecast.GW P),"0") AS GWP
SELECT tblStaticAllFor ecast.LOB
FROM tblStaticAllFor ecast
WHERE (((tblStaticAll Forecast.Divisi onIDFK)=[forms].[Rpt_Summary].[cboDivision]) AND ((tblStaticAllF orecast.YearID) =[forms].[Rpt_Summary].[cboYear]) AND ((tblStaticAllF orecast.MonthID )=[forms].[Rpt_Summary].[cboMonth]) AND ((Val([Binding_Percent age]))>="75"))
GROUP BY tblStaticAllFor ecast.LOB
ORDER BY tblStaticAllFor ecast.LOB
PIVOT "Week " & Format([FWeek]) In ("Week 1","Week 2","Week 3","Week 4","Week 5");
[/code]
On top of that, to tie in the BudgetGWP & PriorGWP values that are located on different tables has left me in a desperate state….. I have also read that in a crosstab query, I can specify only one value field and one column heading field.
Can anyone help me on this. I have run out of ideas due to my lack of experience. How would you go about trying to get the dataset in the format needed to create the report.
I hope someone is out there to shed some light on the subject.
Thanks,
Keith.
Background:
The report is different than anything I have done but I am hoping that for someone out there has. Visually it looks like the following:
Product Name__Week 1__Week 2__Week 3__Week 4__Week 5__BudgetGWP__P riorGWP
Product 1________45____ __56_______0___ ____0_______12_ ______300______ ___250__
Product 2________60____ __66_______0___ ____0_______11_ ______250______ ___225__
Product 3________45____ __56_______0___ ____0_______12_ ______300______ ___225__
Product 4________0_____ __0________0___ ____0_______0__ ______50_______ ___40___
Product 5________45____ __56_______0___ ____0_______12_ ______412______ ___335__
Product 6________0_____ __0________0___ ____0_______0__ ______41_______ ___32___
Etc……
The values for column headings Weeks 1-5 are coming from one table called “tblStaticAllFo recast”. This table includes my Product Name field and Weeks 1 -5 is a field called “FWeek” in which the user can select a drop down list of numbers 1-5.
The values for column heading BudgetGWP are coming from one table called “tblbudget”. This table includes my Product Name field.
The values for column heading PriorGWP are coming from one table called “tblPrior”. This table includes my Product Name field.
All of the tables have a filed called “GWP” of which the values in this report are based upon. As you can see on the report I displayed I have scenarios where there are products of which nothing was sold across the weeks or in certain weeks only.The values for column heading BudgetGWP are coming from one table called “tblbudget”. This table includes my Product Name field.
The values for column heading PriorGWP are coming from one table called “tblPrior”. This table includes my Product Name field.
I need to display all products of which in my case there are 22.
I also need to display a column heading called Week 1, 2, 3, ,, when I only have a field called FWeek.
Current State:
Like I said I have been struggling with this type of report. I have been going down the crosstab query road to build a part of this report. I figured out how to use the “In Clause” to create the column headings I needed (Week 1 , 2, 3, ,,), populate zeros where no values were found (Using “Nz” in my sum expression of GWP) but how to get ALL products to list has eluded me. Below is what I have so far on the crosstab query:
[code=vb]
TRANSFORM Nz(Sum(tblStati cAllForecast.GW P),"0") AS GWP
SELECT tblStaticAllFor ecast.LOB
FROM tblStaticAllFor ecast
WHERE (((tblStaticAll Forecast.Divisi onIDFK)=[forms].[Rpt_Summary].[cboDivision]) AND ((tblStaticAllF orecast.YearID) =[forms].[Rpt_Summary].[cboYear]) AND ((tblStaticAllF orecast.MonthID )=[forms].[Rpt_Summary].[cboMonth]) AND ((Val([Binding_Percent age]))>="75"))
GROUP BY tblStaticAllFor ecast.LOB
ORDER BY tblStaticAllFor ecast.LOB
PIVOT "Week " & Format([FWeek]) In ("Week 1","Week 2","Week 3","Week 4","Week 5");
[/code]
On top of that, to tie in the BudgetGWP & PriorGWP values that are located on different tables has left me in a desperate state….. I have also read that in a crosstab query, I can specify only one value field and one column heading field.
Can anyone help me on this. I have run out of ideas due to my lack of experience. How would you go about trying to get the dataset in the format needed to create the report.
I hope someone is out there to shed some light on the subject.
Thanks,
Keith.
Comment