Forum Discussion
Incorrect Moving Average Date and Sum
- 8 years ago
Hi devleena,
Please try this solution to calculate moving average without adding a calendar table.
In Query Editor mode, sort the field 'DoolallySales doolally_pos_master_staging'[pos_order_date] in Ascending order. Then, add an index column.
Then, in report view, add DoolallySales doolally_pos_master_staging'[pos_order_date] into table visual, create measues like this:
TotalSales = SUM([final_total]) Rolling 7 day SUM2 = IF ( MAX ( doolally_pos_master_staging[Index] ) < 7, BLANK (), CALCULATE ( [TotalSales], FILTER ( ALL ( doolally_pos_master_staging ), doolally_pos_master_staging[Index] <= MAX ( doolally_pos_master_staging[Index] ) && doolally_pos_master_staging[Index] > MAX ( doolally_pos_master_staging[Index] ) - 7 ) ) ) Rolling 7 day Average2 = IF ( MAX ( doolally_pos_master_staging[Index] ) < 7, BLANK (), CALCULATE ( [TotalSales], FILTER ( ALL ( doolally_pos_master_staging ), doolally_pos_master_staging[Index] <= MAX ( doolally_pos_master_staging[Index] ) && doolally_pos_master_staging[Index] > MAX ( doolally_pos_master_staging[Index] ) - 7 ) ) ) / 7Best regards,
Yuliana Gu
Hmm, not sure what is going on but try posting your data as text that can be copied. Also, you might look at my Time Intelligence The Hard Way Quick Measure: https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008
Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The amount being calculated is correct . There is a gap in the record , 22nd Novemeber 2015 is not there.
So I switched on the key for showing null values and the math is now working fine.
What I still not being able to do is, ignore the first 7 days where there is no rollup sum.