Forum Discussion
Combined running total
Hello,
Trying to rite a measure to display running total by date and combine the two running totals.
I would like to have 3 measures as below.
1. running total up to yesterday
2. running total from today (including today)
3. combine running total 1 &2
Thanks!
**updated data
Hi topazz11 ,
I created a sample with some measures that you can have a try.
- Create a calendar table
Table 2 = CALENDARAUTO()
- Create some measures
Running total 1 (up to yesterday) = IF ( MAX ( 'Table'[Date ] ) >= DATE ( 2019, 7, 5 ) || MAX ( 'Table'[Date ] ) = BLANK (), BLANK (), CALCULATE ( SUM ( 'Table'[Item] ), FILTER ( ALL ( 'Table' ), 'Table'[Date ] <= MAX ( 'Table 2'[Date] ) && 'Table'[Date ] < DATE ( 2019, 7, 5 ) ) ) )Running total 2 (from today) = IF ( MAX ( 'Table'[Date ] ) < DATE ( 2019, 7, 5 ) || MAX ( 'Table'[Date ] ) = BLANK (), BLANK (), CALCULATE ( SUM ( 'Table'[Item] ), FILTER ( ALL ( 'Table' ), 'Table'[Date ] >= DATE ( 2019, 7, 5 ) && 'Table'[Date ] <= MAX ( 'Table 2'[Date] ) ) ) )Measure =
IF (
MAX ( 'Table'[Date ] ) < DATE ( 2019, 7, 5 ),
[Running total 1 (up to yesterday)],
[Running total 2 (from today)]
)
Combine Runing =
IF (
'Table 2'[Measure] = BLANK (),
BLANK (),
CALCULATE (
SUMX ( 'Table', [Measure] ),
FILTER ( ALL ( 'Table' ), 'Table'[Date ] <= MAX ( 'Table 2'[Date] ) )
)
)Here is my sample that you can download.
2 Replies
- nlouahedjNew Member
Hello,
I think there is an error in your alculations otherise you should get this output; if it not the case please explaine more how the calculations are working in your exemple!
You an check this article for cumulativ totals https://www.daxpatterns.com/cumulative-total/
- v-xuding-msftCommunity Support
Hi topazz11 ,
I created a sample with some measures that you can have a try.
- Create a calendar table
Table 2 = CALENDARAUTO()
- Create some measures
Running total 1 (up to yesterday) = IF ( MAX ( 'Table'[Date ] ) >= DATE ( 2019, 7, 5 ) || MAX ( 'Table'[Date ] ) = BLANK (), BLANK (), CALCULATE ( SUM ( 'Table'[Item] ), FILTER ( ALL ( 'Table' ), 'Table'[Date ] <= MAX ( 'Table 2'[Date] ) && 'Table'[Date ] < DATE ( 2019, 7, 5 ) ) ) )Running total 2 (from today) = IF ( MAX ( 'Table'[Date ] ) < DATE ( 2019, 7, 5 ) || MAX ( 'Table'[Date ] ) = BLANK (), BLANK (), CALCULATE ( SUM ( 'Table'[Item] ), FILTER ( ALL ( 'Table' ), 'Table'[Date ] >= DATE ( 2019, 7, 5 ) && 'Table'[Date ] <= MAX ( 'Table 2'[Date] ) ) ) )Measure =
IF (
MAX ( 'Table'[Date ] ) < DATE ( 2019, 7, 5 ),
[Running total 1 (up to yesterday)],
[Running total 2 (from today)]
)
Combine Runing =
IF (
'Table 2'[Measure] = BLANK (),
BLANK (),
CALCULATE (
SUMX ( 'Table', [Measure] ),
FILTER ( ALL ( 'Table' ), 'Table'[Date ] <= MAX ( 'Table 2'[Date] ) )
)
)Here is my sample that you can download.