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
topazz11
Helper III
Helper III

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

que3.JPG

1 ACCEPTED SOLUTION
v-xuding-msft
Community Support
Community Support

Hi @topazz11 ,

I created a sample with some measures that you can have a try.

  • Create a calendar table

 

Table 2 = CALENDARAUTO()

1.PNG

 

  • 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] ) )
)
)

2.PNG

Here is my sample that you can download.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hi @topazz11 ,

I created a sample with some measures that you can have a try.

  • Create a calendar table

 

Table 2 = CALENDARAUTO()

1.PNG

 

  • 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] ) )
)
)

2.PNG

Here is my sample that you can download.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
nlouahedj
New 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!

 

image.png

You an check this article for cumulativ totals https://www.daxpatterns.com/cumulative-total/

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.