Hi guys,
Could you help me resolve this issue on the reporter
My user is requesting last four week average for all weeks in a year.
My data is
Week >> week Index >> Measure1 >> Last four weekaverage
2001W01 >> 53 >> 10 >> 25
2001W02 >> 54 >> 20 >> 25
2001W03 >> 55 >> 30 >> 25
2001W04 >> 56 >> 40 >> 25
2001W05 >> 57 >> 10 >> 25
2001W06 >> 58 >> 20 >> 25
2001W07 >> 59 >> 30 >> 25
2001W08 >> 60 >> 40 >> 25
2001W09 >> 61 >> 10 >> 25
2001W10 >> 62 >> 20 >> 25
2001W11 >> 63 >> 30 >> 25
2001W12 >> 64 >> 40 >> 25
2001W13 >> 65 >> 10 >> 25
2001W14 >> 66 >> 20 >> 25
2001W16 >> 68 >> 40 >> 18.75
In the above data Lastfourweekaverage is the column which i need to calculate and show up on the report.
here the last 4 week average can be calculated as sum of measures where ( Week index of current row + (Week index of current row -1) +(Week index of current row -2) + (Week index of current row -3))
I cannot use function because if i dont have data for a week in between say week 15 does not have data then my average for 16 is (w16+W14+W13+W12)/4 which is wrong i always want my week 16 average as ( w16+W15+W14+W13)
I have created this weekindex object so that i can just subract (1) on the index to get the previous value of that weekindex.
This logic is mission critical as i have reports where in we use last 4 week average ,8 week average and 13 average and compare this quarter sales to sales last year same quarter, Compare quarterly sales to previous quarter sales and so many other calculations using the time related functions like previous month, year and so on.
Ur help in this regard is appreciated.
Thanks in Advance
Ramnath
ramknath (BOB member since 2002-09-24)