Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
tasmia93
Microsoft Employee
Microsoft Employee

DAX Running Total/Cumulative Sum for Dimension

Hi, 
 

I am trying to get the cumulative total of products on this combo chart. I need the line to display the total running sum of the products starting with the largest sales. I tried using the DAX for date running sums but I cannot get it to work for products. Any help would be appreciated!

 

tasmia93_0-1723745623367.png

 

1 ACCEPTED SOLUTION
tasmia93
Microsoft Employee
Microsoft Employee

Thank you all for responses. I was able to get it working with the following DAX

Running Total Sale2 = 

VAR thissubcat =
    MIN ( 'Product'[Product] )
VAR summary =
    ADDCOLUMNS ( ALLSELECTED ( Product[Product] ), "cTS", [Total Sales] )
VAR thisTS =
    SUMX ( FILTER ( summary, Product[Product] = thissubcat ), [cTS] )
VAR result =
    SUMX ( FILTER ( summary, [cTS] >= thisTS ), [cTS] )
RETURN
    result

View solution in original post

3 REPLIES 3
tasmia93
Microsoft Employee
Microsoft Employee

Thank you all for responses. I was able to get it working with the following DAX

Running Total Sale2 = 

VAR thissubcat =
    MIN ( 'Product'[Product] )
VAR summary =
    ADDCOLUMNS ( ALLSELECTED ( Product[Product] ), "cTS", [Total Sales] )
VAR thisTS =
    SUMX ( FILTER ( summary, Product[Product] = thissubcat ), [cTS] )
VAR result =
    SUMX ( FILTER ( summary, [cTS] >= thisTS ), [cTS] )
RETURN
    result
Anonymous
Not applicable

Hi, @tasmia93 

I create a sample table:

vyohuamsft_0-1724037500206.png

 

Then create a measure and try the following DAX expression:

Running Total Sale = 
VAR CurrentProduct = MAX('Table'[ProductKey])
RETURN
    CALCULATE(
        [Total Sales],
        FILTER(
            ALL('Table'),
            'Table'[Sales] >= CALCULATE(MAX('Table'[Sales]), 'Table'[ProductKey] = CurrentProduct)&&'Table'[ProductKey]<=MAX('Table'[ProductKey])
        )
    )

 

Here is my preview:

vyohuamsft_1-1724037555452.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

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

Idrissshatila
Super User
Super User

Hello @tasmia93 ,

 

try the following 

rank your products based on their total sales

ProductRank = 
RANKX(
    ALL('Product'),
    [Total Sales],
    , 
    DESC
)

 

Running Total Sales = 
VAR MaxRank = MAX('Product'[ProductRank])
RETURN
    CALCULATE(
        [Total Sales],
        FILTER(
            ALL('Product'),
            'Product'[ProductRank] <= MaxRank
        )
    )


Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.