Search code examples
powerbimeasure

How to calculate running total of a measure


I have this measure

Average Spend =
CALCULATE ( SUM ( Table[Spend] ) ) / CALCULATE ( SUM ( Table[Volume] ) )

The table has a variable month that the data is grouped by

Month  Spend   Customers  var_x   var_y
1      100       10        A       C
2      300       10        A       B
3      500       10        A       C

I want to have a graph showing running total spend per customer, so x axis would be month and y axis would be average_spend

Any ideas?


Solution

  • Plain vanilla:

    Go to Quick Measure, select Running total and pull in your measure and the Month column. That's it.

    enter image description here

    The result will look like this:

    enter image description here

    And here's the expression that Power BI created for you:

    Average Spend running total in Month = 
    CALCULATE(
        [Average Spend],
        FILTER(
            ALLSELECTED('Table'[Month]),
            ISONORAFTER('Table'[Month], MAX('Table'[Month]), DESC)
        )
    )