Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
MAG_PRG
Regular Visitor

Running total of a measure

I have a table with a set of values and dates that span two years. I have a filter to select year, and I created a measure to show the values for the last year as well. For both current and last year I have created measures for the running total. I also created a measure showing the difference between the running totals. Here are the graphs for these measures:

MAG_PRG_0-1635162208319.png

What I am having a problem with is creating a running total of the last one, meaning a running total of the changes between current and last years running totals. I can't use the SUM function on the last measure, and everything I've tried so far just gives me the same measure. Is this something that is possible to do?

The real data I am working on is pretty complicated, so I created this simple report for testing, where the screenshot from above is from:   https://www.dropbox.com/s/efyf7feokqsgzes/pbi-running-total-test.pbix?dl=0

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@MAG_PRG Try this:

NEW_RunningTotalChange = var DatesTableThisYear=CALCULATETABLE(VALUES('Values'[Date]);DATESYTD('Dates'[Date]))
var tempTable=ADDCOLUMNS(DatesTableThisYear;"_change";CALCULATE(SUM('Values'[Value]);DATESYTD('Dates'[Date]))-CALCULATE(SUM('Values'[Value]);SAMEPERIODLASTYEAR(DATESYTD('Dates'[Date]))))
return SUMX(tempTable;[_change])

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

@MAG_PRG Try this:

NEW_RunningTotalChange = var DatesTableThisYear=CALCULATETABLE(VALUES('Values'[Date]);DATESYTD('Dates'[Date]))
var tempTable=ADDCOLUMNS(DatesTableThisYear;"_change";CALCULATE(SUM('Values'[Value]);DATESYTD('Dates'[Date]))-CALCULATE(SUM('Values'[Value]);SAMEPERIODLASTYEAR(DATESYTD('Dates'[Date]))))
return SUMX(tempTable;[_change])

It worked, thanks! Creating a temp table was a neat trick, gonna have to remember that one.

amitchandak
Super User
Super User

@MAG_PRG , Please try either YTD with a date table

example

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))

 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected(date),date[date] <=max(date[Date])))

It's not exactly what I am after. On the middle graph I posted above I have the running total for current and last year. On the bottom graph I take the difference between current and last year from the graph above. What I need is a running total of the bottom graph, but since that is a measure I can't use the SUM function.

I have these measures:
Running total current year:

MAG_PRG_2-1635167937421.png

Running total last year:

MAG_PRG_3-1635167964920.png

Running total change(Total running current year - total running last year)

MAG_PRG_4-1635168010353.png


What I need is a running total of the last measure(bottom graph).



 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.