Forum Discussion
How to Create a Dynamic Running Total in DAX That Responds to Slicers and Filters
Hi Power BI Community,
I am trying to create a running total measure in DAX that updates dynamically based on filters applied in the report - like Date, Product Category, or Region.
I have tried using TOTALYTD and CALCULATE with FILTER , but the results are not accurate when slicers are used. The running total doesn’t always reflect the filtered data correctly.
Am looking for a DAX formula that:
Calculates a running total
Works with all slicers and filters
Updates based on the selected date range or other fields
Any help or examples would be greatly appreciated!
Thanks in Advance!
Hi Anonymous
You can create a dynamic running total using CALCULATE, SUM, and a date filter condition like this:
Running Total =
CALCULATE(
SUM(Sales[Amount]),
FILTER(
ALLSELECTED(Date[Date]),
Date[Date] <= MAX(Date[Date])
)
)
Thanks
4 Replies
- burakkaragoz
Super User
Hi Anonymous ,
I get what you mean about the running total not updating correctly with slicers or filters, that’s a pretty common DAX headache. When you want a running total that’s fully dynamic and respects all the slicers and filters, you usually wanna avoid TOTALYTD unless it’s a simple date scenario.
Try using something like this instead (assuming you have a Date table connected properly):
CodeRunning Total = CALCULATE( SUM('YourTable'[YourValue]), FILTER( ALLSELECTED('YourTable'[DateColumn]), 'YourTable'[DateColumn] <= MAX('YourTable'[DateColumn]) ) )This formula sums up your [YourValue] column up to the max date in the current filter context, which means it should respect whatever slicers or filters the user applies (date range, product, whatever). Just make sure your Date table is marked as a Date Table and relationships are set up correctly.
If you want to get even more flexible, swap 'YourTable'[DateColumn] with your actual date field and 'YourTable'[YourValue] with the field you want to total.
Let me know if you run into any issues or need a tweak for your specific scenario!
If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
translation and formatting supported by AI - rajendraongole1
Super User
Hi Anonymous - you can use the CALCULATE function along with FILTER and ALLSELECTED.
eg:
Running Total =
CALCULATE(
SUM('YourTable'[SalesAmount]), -- replace with your measure/column
FILTER(
ALLSELECTED('YourDateTable'[Date]), -- respects slicers
'YourDateTable'[Date] <= MAX('YourDateTable'[Date])
)
)try the above logic and replace with your table as per model. Hope this helps.
- Abhilash_P
Super User
Hi Anonymous
You can create a dynamic running total using CALCULATE, SUM, and a date filter condition like this:
Running Total =
CALCULATE(
SUM(Sales[Amount]),
FILTER(
ALLSELECTED(Date[Date]),
Date[Date] <= MAX(Date[Date])
)
)
Thanks - ryan_mayu
Super User
Anonymous
you can also try to use new visual calculation to get running total