Hi,
My table contains a MonthNumber (values 1 to 12) and fields called 'Y10-11', 'Y11-12', etc. which contain numbers of widgets (let’s say) produced in that month. I need a query to calculate running totals for each year and found this thread very helpful (thanks Mahjenk2)
Using that I came up with this:
...and corresponding functions for the other years.
I added the If...Is Null part to stop the query from carrying the current value forward for months that haven’t elapsed yet. However that has produced a minor problem. In my data, there were no widgets produced in month 11 of Y10-11. Therefore the query does not return a cumulative value for that month, but goes back to normal the next month.
The attached report will probably explain it better. I’m charting it too for a visual comparison between years and you can see the corresponding gap in the results. I guess I could find the option to interpolate the missing data rather than show a gap, but for “tidiness”, I’d like to get the query to return the right value so it can be included in the report.
But the solution must still allow for the future months (in the current year) to show null.
Any ideas how this can be done?
Thanks,
Pat.
My table contains a MonthNumber (values 1 to 12) and fields called 'Y10-11', 'Y11-12', etc. which contain numbers of widgets (let’s say) produced in that month. I need a query to calculate running totals for each year and found this thread very helpful (thanks Mahjenk2)
Using that I came up with this:
Code:
IIf([Y11-12] Is Null,Null,Nz(DSum("[Y11-12]","MCRNByMonth","[MonthNumber]<=" & [ExistingMonthNo]),0))
...and corresponding functions for the other years.
I added the If...Is Null part to stop the query from carrying the current value forward for months that haven’t elapsed yet. However that has produced a minor problem. In my data, there were no widgets produced in month 11 of Y10-11. Therefore the query does not return a cumulative value for that month, but goes back to normal the next month.
The attached report will probably explain it better. I’m charting it too for a visual comparison between years and you can see the corresponding gap in the results. I guess I could find the option to interpolate the missing data rather than show a gap, but for “tidiness”, I’d like to get the query to return the right value so it can be included in the report.
But the solution must still allow for the future months (in the current year) to show null.
Any ideas how this can be done?
Thanks,
Pat.