Forum Discussion
Cumulative total by date
Hello,
I am trying to get two running totals as example below.
First one is for the toral up to yesterday (Today-1)
Second one is for the total on&after today.
I tried these DAX...but doesnt work.
Running total 1 :=
CALCULATE (
[Total Sales],
FILTER (
ALL ( DimDate[Datekey] ),
DimDate[Datekey] < Today( ( DimDate[Datekey] ) )
)
)
Running total 2 :=
CALCULATE (
[Total Sales],
FILTER (
ALL ( DimDate[Datekey] ),
DimDate[Datekey] >= Today( ( DimDate[Datekey] ) )
)
)
Any help would be greatly appreciated!
topazz11 there are few ways to do this, here is one, add following measures
Upto Today = CALCULATE( [Sum Item1], FILTER( ALL( 'Date'[Date1] ), 'Date'[Date1] <= MAX( 'Date'[Date1] )) ) * IF( MAX( 'Date'[Date1] ) < TODAY(), 1 ) From Today = CALCULATE( SUM( 'Table'[Item2] ), FILTER( ALL( 'Date'[Date1] ), 'Date'[Date1] <= MAX( 'Date'[Date1] ) && 'Date'[Date1] >= TODAY() ))* DIVIDE( [Sum Item2], [Sum Item2])sum item1 and sum item 2 measures are just sum of respectice columns
Have you tried the built-in running total quick measures? Also, See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008
3 Replies
- parry2k
Super User
topazz11 there are few ways to do this, here is one, add following measures
Upto Today = CALCULATE( [Sum Item1], FILTER( ALL( 'Date'[Date1] ), 'Date'[Date1] <= MAX( 'Date'[Date1] )) ) * IF( MAX( 'Date'[Date1] ) < TODAY(), 1 ) From Today = CALCULATE( SUM( 'Table'[Item2] ), FILTER( ALL( 'Date'[Date1] ), 'Date'[Date1] <= MAX( 'Date'[Date1] ) && 'Date'[Date1] >= TODAY() ))* DIVIDE( [Sum Item2], [Sum Item2])sum item1 and sum item 2 measures are just sum of respectice columns
- Greg_Deckler
Community Champion
Have you tried the built-in running total quick measures? Also, See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008 - NiraNew Member
How could this be achieved in POwer Query(performance will be affected)? calculate the cumulative total for a Purchase Oder until it reaches its maximum date.
123 1.2.2022 5units cumulative 5units
123 3.2.2022 2units cumulative 7units
123 5.2.2022 6units cumulative 13units
How could I achieve th ecumulative total in a column in POwer query?
Thank you