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.
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
Solved! Go to Solution.
Hi @topazz11 ,
I created a sample with some measures that you can have a try.
Table 2 = CALENDARAUTO()
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.
Hi @topazz11 ,
I created a sample with some measures that you can have a try.
Table 2 = CALENDARAUTO()
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.
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/
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |