-1

im struggling with the following problem. I have categorical variables and and Amount column. What I want to do is, to write a dax measure which calculates the moving/rolling Sum, like you see in the third column "Dax Measure". Did not find any inhouse Dax function for that.

moving sum

EDIT:

Result Table with Dax Measure

Source Table

bonus
  • 1
  • 3

1 Answers1

0

This will work if the category is always sorted ASC.

Dax measure = 
VAR _currentRank = RANKX(ALL('Table'[Category]),CALCULATE(MIN('Table'[Category])),,ASC)
RETURN
CALCULATE(
    CALCULATE(SUM('Table'[Amount]),TOPN(_currentRank,VALUES('Table'[Category]),MIN([Category]))),
    ALL('Table'[Category])
)

Using RANKX to define the other and aggregating for all the item before it.

mxix
  • 3,539
  • 1
  • 16
  • 23