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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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