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

cummulative total of volume

Hi everyone, 

i have a table that details the products, when and where they were produced and the volume

SeriesProductPlant Volume
2024Product 1Plant 1 333
2024Product 8Plant 1 100
2024Product 3Plant 2 533
2024Product 7Plant 1 133
2024Product 10Plant 2 67
2025 
2024Product 2plant 1 300
2024Product 10Plant 1 33
2024Product 6Plant 2 333
2024Product 7Plant 2 267
2024Product 8Plant 2 200
2024Product 9Plant 2 133
2024Product 1Plant 2 667
2024Product 2plant 2 600
2024Product 9Plant 1 67
2024Product 3Plant 1 267
2024Product 4Plant 1 233
2024Product 5Plant 1 200
2024Product 6Plant 1 167
2024Product 4Plant 2 467
2024Product 5Plant 2 400

 

I want to create a visual that shows the products, the sum of volume (sorted descending) and the accumulated volume (like the one below). In the context i will also filter for "year" (let's say 2024)

ProductVol finalCumul Vol
Product 11,0001,000
Product 29001,900
Product 38002,700
Product 47003,400
Product 56004,000
Product 65004,500
Product 74004,900
Product 83005,200
Product 92005,400
Product 101005,500
 5,5005,500




I can create the visual but I can't create the Cummulative measure in DAX. i've been crunching my brain without success. Can you please help me?

thanks in advance!!!!!

nico

2 ACCEPTED SOLUTIONS
speedramps
Community Champion
Community Champion

Well done @johnt75.

 

Here is another varient with some comments ...

Cumulative = 
// create a temp table of volume total by product
VAR SummaryTable = 
    ADDCOLUMNS(
    ALLSELECTED( 'Table'[Product]),
    "@volume", CALCULATE(SUM('Table'[Volume]))
)
// get the current product total
VAR myvolume = SUM('Table'[Volume])

// filter the summary table >= the current
VAR mysubset = FILTER(SummaryTable, [@volume] >= myvolume)

RETURN 
// sum the values in the subset
SUMX(mysubset, [@volume])

 

speedramps_0-1750085769948.png

 

View solution in original post

v-dineshya
Community Support
Community Support

Hi @nicoenz ,

Thank you for reaching out to the Microsoft Community Forum.

 

Please follow below steps.

1. Imported sample data into Power bi desktop. Please refer snap.

 

vdineshya_1-1750145450345.png

 

2.  Created Total volume measure "Total Volume" with below DAX code.

 

     Total Volume = SUM('Data'[Volume])

 

3.  Created Cumulative Volume Measure "Cumulative Volume"  with below DAX code.

 

Cumulative Volume =

VAR CurrentProduct = SELECTEDVALUE('Data'[Product])
RETURN
CALCULATE(
    [Total Volume],
    FILTER(
        ALLSELECTED('Data'[Product]),
        [Total Volume] >= CALCULATE([Total Volume], 'Data'[Product] = CurrentProduct)
    )
)
 
4. In table visual, Drag the Product, Total Volume, Cumulative Volume and Series fileds in visual. To filter the "2024" data, In visual pane mention the Series as "2024" as in snap. Please refer output snap and PBIX file.
 

 

vdineshya_0-1750145396698.png

 

If my response has resolved your query, please mark it as the "Accepted Solution" to assist others. Additionally, a "Kudos" would be appreciated if you found my response helpful.

Thank you

 

View solution in original post

5 REPLIES 5
v-dineshya
Community Support
Community Support

Hi @nicoenz ,

Thank you for reaching out to the Microsoft Community Forum.

 

Please follow below steps.

1. Imported sample data into Power bi desktop. Please refer snap.

 

vdineshya_1-1750145450345.png

 

2.  Created Total volume measure "Total Volume" with below DAX code.

 

     Total Volume = SUM('Data'[Volume])

 

3.  Created Cumulative Volume Measure "Cumulative Volume"  with below DAX code.

 

Cumulative Volume =

VAR CurrentProduct = SELECTEDVALUE('Data'[Product])
RETURN
CALCULATE(
    [Total Volume],
    FILTER(
        ALLSELECTED('Data'[Product]),
        [Total Volume] >= CALCULATE([Total Volume], 'Data'[Product] = CurrentProduct)
    )
)
 
4. In table visual, Drag the Product, Total Volume, Cumulative Volume and Series fileds in visual. To filter the "2024" data, In visual pane mention the Series as "2024" as in snap. Please refer output snap and PBIX file.
 

 

vdineshya_0-1750145396698.png

 

If my response has resolved your query, please mark it as the "Accepted Solution" to assist others. Additionally, a "Kudos" would be appreciated if you found my response helpful.

Thank you

 

speedramps
Community Champion
Community Champion

Well done @johnt75.

 

Here is another varient with some comments ...

Cumulative = 
// create a temp table of volume total by product
VAR SummaryTable = 
    ADDCOLUMNS(
    ALLSELECTED( 'Table'[Product]),
    "@volume", CALCULATE(SUM('Table'[Volume]))
)
// get the current product total
VAR myvolume = SUM('Table'[Volume])

// filter the summary table >= the current
VAR mysubset = FILTER(SummaryTable, [@volume] >= myvolume)

RETURN 
// sum the values in the subset
SUMX(mysubset, [@volume])

 

speedramps_0-1750085769948.png

 

worked perfectly well. by not using the relation parameter in the WINDOW parameter.

Thanks for the help

johnt75
Super User
Super User

You can create a measure like

Cumulative Volume = 
VAR SummaryTable = ADDCOLUMNS(
    ALLSELECTED( 'Table'[Product] ),
    "@vol", [Vol] 
)
VAR Result = SUMX(
    WINDOW(
        1, ABS,
        0, REL,
        SummaryTable,
        ORDERBY( [@vol], DESC, 'Table'[Product], ASC )
    ),
    [@vol]
)
RETURN Result

The input table has duplicate values. Therefore I got an error message: "WINDOW's Relation parameter may have duplicate rows. This is not allowed".

But I understand the logic of your measure. Thank you very much!!!!!!

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.