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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Calculate cumulative percentage by group

Hello guys,

 

I am just starting out with DAX and I wanted to get some idea on how to do the following. I have a single Table that records sales transcations for "Products". Each transcation has a "Sales_quantity" and "Price". Additionally, the table has a "%Sales" Column that records the percentage of sales of the transcation for the product as a whole, which I've already calculated. What I need is the blue column "Target" that calculates the cumulative %Sales of each Group ranked by Price but i have no idea how to use DAX to calculate this column. Can you help me out here?

 

ProductSales_quantityPrice%SalesTarget
A2000366,66%100%
A1000233,33%33,33%
B20002020%50%
B30001830%30%
B50002150%100%
1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Create a calculated column using the below

Target = 
var currentPrice = 'Table'[Price]
var totalSales = CALCULATE( SUM('Table'[Sales_quantity]), ALLEXCEPT('Table','Table'[Product]) )
var filteredSales = CALCULATE( SUM('Table'[Sales_quantity]), ALLEXCEPT('Table','Table'[Product]),'Table'[Price] <= currentPrice )
return DIVIDE( filteredSales, totalSales )

View solution in original post

1 REPLY 1
johnt75
Super User
Super User

Create a calculated column using the below

Target = 
var currentPrice = 'Table'[Price]
var totalSales = CALCULATE( SUM('Table'[Sales_quantity]), ALLEXCEPT('Table','Table'[Product]) )
var filteredSales = CALCULATE( SUM('Table'[Sales_quantity]), ALLEXCEPT('Table','Table'[Product]),'Table'[Price] <= currentPrice )
return DIVIDE( filteredSales, totalSales )

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.