Forum Discussion
Rolling value calculation
- Anonymous4 years ago
Hi Anonymous ,
Here are the steps you can follow:
1. Create calculated table.
Table = CALENDAR(MIN('Table1'[Date]),MAX('Table1'[Date]))2. Create measure.
MeasureA = var _mindate=MINX(ALLSELECTED('Table'),[Date]) var _maxdate=MAXX(ALLSELECTED('Table'),[Date]) return DIVIDE( SUMX(FILTER(ALL(Table1), 'Table1'[Date]>=_mindate&&'Table1'[Date]<=_maxdate),[StoreA]), SUMX( FILTER(ALL(Table2), 'Table2'[Date]>=_mindate&&'Table2'[Date]<=_maxdate&&'Table2'[Store]="A"),[Sales]))MeasureB = var _mindate=MINX(ALLSELECTED('Table'),[Date]) var _maxdate=MAXX(ALLSELECTED('Table'),[Date]) return DIVIDE( SUMX(FILTER(ALL(Table1), 'Table1'[Date]>=_mindate&&'Table1'[Date]<=_maxdate),[StoreB]), SUMX( FILTER(ALL(Table2), 'Table2'[Date]>=_mindate&&'Table2'[Date]<=_maxdate&&'Table2'[Store]="B"),[Sales]))3. Result:
If you need pbix, please click here.
Rolling value calculation.pbix
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi Anonymous ,
Here are the steps you can follow:
1. Create calculated table.
Table =
CALENDAR(MIN('Table1'[Date]),MAX('Table1'[Date]))
2. Create measure.
MeasureA =
var _mindate=MINX(ALLSELECTED('Table'),[Date])
var _maxdate=MAXX(ALLSELECTED('Table'),[Date])
return
DIVIDE(
SUMX(FILTER(ALL(Table1),
'Table1'[Date]>=_mindate&&'Table1'[Date]<=_maxdate),[StoreA]),
SUMX(
FILTER(ALL(Table2),
'Table2'[Date]>=_mindate&&'Table2'[Date]<=_maxdate&&'Table2'[Store]="A"),[Sales]))MeasureB =
var _mindate=MINX(ALLSELECTED('Table'),[Date])
var _maxdate=MAXX(ALLSELECTED('Table'),[Date])
return
DIVIDE(
SUMX(FILTER(ALL(Table1),
'Table1'[Date]>=_mindate&&'Table1'[Date]<=_maxdate),[StoreB]),
SUMX(
FILTER(ALL(Table2),
'Table2'[Date]>=_mindate&&'Table2'[Date]<=_maxdate&&'Table2'[Store]="B"),[Sales]))
3. Result:
If you need pbix, please click here.
Rolling value calculation.pbix
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi Yang,
Thanks for the quick response.
The equation is working but if I visualize it in a line chart, it only show 1 result, is there any possibility that it can show also the cumulative trend from 2021 to 2022?
I tried to do this in excel as exmaple, not sure if it works in power BI
Thank you.