Forum Discussion
Anonymous
3 years agoNot applicable
Rolling average Last Month and Current Month
Hi, I have two tables: BLUE: Table used for Date slider/slicer RED: Table used for all other dimensions/measures I am plotting 'sum of flag' in a timeline. I wish to plot r...
- 3 years ago
Hi Anonymous ,
Sorry about that, try this:myMeasure = VAR _monthNumberCurrent = MAX ( mytable[monthNumber] ) //get the month number from this row var _thisMonthFlag = MAX(myTable[Flag]) VAR _prevMonthNumber = CALCULATE ( MAX ( mytable[monthNumber] ), FILTER ( ALL ( myTable ), myTable[monthNumber] < _monthNumberCurrent ) ) //filter the table to all month numbers less than this month number, and get the max value which is the month before var _lastMonthFlag = CALCULATE(MAX(myTable[Flag]),FILTER(ALL(myTable),myTable[MonthNumber]=_prevMonthNumber)) RETURN DIVIDE ( _thisMonthFlag + _lastMonthFlag, IF(_lastMonthFlag = 0,1,2 ))
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
JohnShepherdAPD
Helper II
3 years agoHi Saniat, take a look at the window function, some explanation is here:
https://www.sqlbi.com/articles/introducing-window-functions-in-dax/