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
Anonymous
Not applicable

Running Total Through Direct Query

I need to calculate the running total for a tabular data. I need to use direct query mode.

There are Filters(Slicers) for Date and Product in the report. When we filter the data based on Date and Product, the running total should be calculated as per the filtered applied.

 

DateProductCostRunning Total
1/1/2019A1010
1/1/2019B2030
1/1/2019C2555
1/2/2019A45100
1/2/2019C65165
1/3/2019B15180
1/3/2019A20200

 

Need help in achieving data like above.

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

@Anonymous ,

 

You may refer to the measure below.

Measure =
CALCULATE (
    SUM ( 'Table1'[Cost] ),
    FILTER (
        SUMMARIZE ( ALLSELECTED ( 'Table1' ), 'Table1'[Date], 'Table1'[Product] ),
        ISONORAFTER (
                'Table1'[Date], MAX ( 'Table1'[Date] ), DESC,
                'Table1'[Product], MAX ( 'Table1'[Product] ), DESC
        )
    )
)
Community Support Team _ Sam Zha
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-chuncz-msft
Community Support
Community Support

@Anonymous ,

 

You may refer to the measure below.

Measure =
CALCULATE (
    SUM ( 'Table1'[Cost] ),
    FILTER (
        SUMMARIZE ( ALLSELECTED ( 'Table1' ), 'Table1'[Date], 'Table1'[Product] ),
        ISONORAFTER (
                'Table1'[Date], MAX ( 'Table1'[Date] ), DESC,
                'Table1'[Product], MAX ( 'Table1'[Product] ), DESC
        )
    )
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-chuncz-msft ,

 

Thank you for your help. 🙂

 

I was able to achieve the required runnning total using the Measure formulae you shared.

 

Thanks,

Ravin

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.