Forum Discussion
JBI
7 years agoFrequent Visitor
Rolling Sum for 5 Days Only
Hi Guys, I want to determine the rolling total of sales, taking only the previous 5 days into account. So if today is the 9th of July 2019, only data from the 5th until now. Rest to be zero. ...
- 7 years ago
hi,
you can try this measure:
Prev 5 days = VAR maxdate = CALCULATE(MAX(Table1[Date]), ALL(Table1)) VAR currentselected = SELECTEDVALUE(Table1[Date]) VAR last5days = maxdate -5 VAR rolling5days = CALCULATE(SUM(Table1[Sales]), FILTER(ALL(Table1[Date]), Table1[Date] > last5days && Table1[Date] <= Currentselected)) RETURN rolling5days
here is the PBI file
cosminc
Post Partisan
7 years agoHi
play with this:
https://community.powerbi.com/t5/Desktop/Rolling-average-on-calculated-table/m-p/693382#M334402
you need Calendar table marked as date table
hope it helps,
Cosmin
Iamnvt
Continued Contributor
7 years agohi,
you can try this measure:
Prev 5 days = VAR maxdate = CALCULATE(MAX(Table1[Date]), ALL(Table1)) VAR currentselected = SELECTEDVALUE(Table1[Date]) VAR last5days = maxdate -5 VAR rolling5days = CALCULATE(SUM(Table1[Sales]), FILTER(ALL(Table1[Date]), Table1[Date] > last5days && Table1[Date] <= Currentselected)) RETURN rolling5days
here is the PBI file