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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
vanya_val
Frequent Visitor

Running total not working as expected in matrix

Hi all,

 

I have a running total measure which seems to work fine when plotted against a date only, however when I try adding it to a matrix with several additional text columns, it no longer works.

 

The requirement is to create a table or matrix listing a series of transactions with their value and running total. Apart from the date and values I also need to include several descriptive columns (Transaction Type, Account, Tech, Cohort Name). As soon as I add the descriptive columns and try listing each single transaction, the running total stops working.

 

In the screenshots I’ve shared below:

 

Value: the value of each single transaction (the actual column is 'Transactions Table'[Cohort])

 

Cumulative: the running total of Value using this formula:

 

Cumulative = calculate(sum('Transactions Table'[Cohort]),filter(ALLSELECTED('Calendar'),'Calendar'[Date] <= max('Calendar'[Date])))

 

Total: the sum of a starting number (63 in this case) and Cumulative. I think this will work if Cumulative works.

 

The measure Cumulative works fine when plotted only against the Date and Value:

 

image1.png

 

However, the requirement is to list every single transaction with some descriptive details. As soon as I try doing that Cumulative no longer works as a running total but instead becomes equal to Value:

 

image2.png

Is there a way to change the DAX for the running total so that it displays correctly when every single item is listed?

Thanks ever so much in advance.

 
6 REPLIES 6
V-pazhen-msft
Community Support
Community Support

@vanya_val 

Try with cumulative total using Earlier in the measure.

Cumulative = calculate(sum('Transactions Table'[Cohort]),filter(all('Transactions Table'),sumx(filter('Transactions Table', earlier('Calendar'[Date])<='Calendar'[Date]),1))

 

Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@V-pazhen-msft  thanks for your reply. I tried the measure you suggested but it doesn't seem to accept the Date column:

 

image4.jpg

@vanya_val 

My bad, should Change the filter table to Calendar table. Give it another try:

 

Cumulative = calculate(sum('Transactions Table'[Cohort]),filter(all('Calendar'),sumx(filter('Calendar', earlier('Calendar'[Date])<='Calendar'[Date]),1))

 


Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@V-pazhen-msft 

Thank you. I'm afraid I'm getting the same issue as with the other measures: it works when plotted only against the date, but as soon as I add another column it stops working 😞

amitchandak
Super User
Super User

@vanya_val , Try if this can help

Cumulative =
VAR _min = MINX(Allselected('Calendar'), 'Calendar'[DATE] )
return
calculate(sum('Transactions Table'[Cohort]),filter(ALLSELECTED('Calendar'),'Calendar'[Date] <= max('Calendar'[Date]) && 'Calendar'[Date] >=_min))

Thanks very much @amitchandak . I've added the measure you suggested as CumulativeTest2 but unfortunately I'm getting the same result as before:

 

image3.jpg

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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