I am trying to create a running total query that aggregates project funding by fiscal year. The fiscal year is calculated based on a date time field that is never null. The totals field comes from 2 different number fields that are either 0 or > 0. The query is going to be linked to by Excel, so I have to do the running total in the query itself, vs. a report.
It is close to working, except that it is not totalling the first fiscal year. The output surrently looks like this:
FYear BudgetedCost IndCont Commitment
2010
2011 8585643 4742000 3843643
2012 22971165 11432165 11539000
2013 36187262 16963282 19223980
2014 44577690 20706644 23871046
2015 49638150 23206644 26431506
As you can see, the first row for FY 2010 is blank. I know there is data there, as this query is fed by a subquery that selects these rows based on contract signed date. Below is the SQL of each query:
and the Aggregate query:
I based this strategy off of this article from Microsoft:
http://support.microsoft.com/kb/290136
I should also mention that I cannot implement the NZ() function, as Excel balks at this when trying to link to Access queries.
It is close to working, except that it is not totalling the first fiscal year. The output surrently looks like this:
FYear BudgetedCost IndCont Commitment
2010
2011 8585643 4742000 3843643
2012 22971165 11432165 11539000
2013 36187262 16963282 19223980
2014 44577690 20706644 23871046
2015 49638150 23206644 26431506
As you can see, the first row for FY 2010 is blank. I know there is data there, as this query is fed by a subquery that selects these rows based on contract signed date. Below is the SQL of each query:
Code:
SELECT Year([DateContractSigned])-IIf([DateContractSigned]<DateSerial(Year([DateContractSigned]),4,1),1,0)+1
AS FYearExport
FROM tblProject
GROUP BY Year([DateContractSigned])-IIf([DateContractSigned]<DateSerial(Year([DateContractSigned]),4,1),1,0)+1, tblProject.ProjID, tblProject.FPAccepted
HAVING (((tblProject.FPAccepted)=True));
and the Aggregate query:
Code:
SELECT qryDashboardChart1.FYearExport,
DSum("[BudgetedCost]","tblProject","Year([DateContractSigned])<=" & [FyearExport]-1 & "")
AS RunTotBudgetedCost, ([RunTotBudgetedCost]-[RunTotTECTERRACommitment])
AS IndustryContribution, DSum("[TECTERRACommitment]","tblProject","Year([DateContractSigned])<=" & [FyearExport]-1 & "")
AS RunTotTECTERRACommitment
FROM qryDashboardChart1
GROUP BY qryDashboardChart1.FYearExport
ORDER BY qryDashboardChart1.FYearExport;
I based this strategy off of this article from Microsoft:
http://support.microsoft.com/kb/290136
I should also mention that I cannot implement the NZ() function, as Excel balks at this when trying to link to Access queries.