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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Avi
New Member

Bucketing Cumulative Total using DAX

Hi

 

How can I represent the following using DAX.

I am trying to Bucket the following Sales Quantity per Customer:

 

CustomerQuantity
A0
A200
A300
B100
C80
C20
D50
D25
D25
D0
TOTAL800

 

and represent the following in Buckets of 3 as Top 20%, Mid 60% and Bottom 20% of the Total as below:

 

 BucketQtyQty %
Top 20%50063%
Mid 60% 20025%
Bottom 20% 10013%
TOTAL800100%

 

Thanks in advance.

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

Hi @Avi,

 

You can create a table like below:

 

Table 2 = SUMMARIZE('Table1','Table1'[Customer],"Total",SUM(Table1[Quantity]))

 

Then create two measures below:

 

Qty = var MA=CALCULATE(MAX('Table 2'[Total]),ALL('Table 2'))
var Mi=CALCULATE(Min('Table 2'[Total]),ALL('Table 2'))
Return
IF(MAX('Table 2'[Total])=MA || MAX('Table 2'[Customer])="D",SUM('Table 2'[Total]),CALCULATE(SUM('Table 2'[Total]),ALL('Table 2'))-MA-Mi )

 

Qty% = var t=CALCULATE(SUM('Table 2'[Total]),ALL('Table 2'))
return 
DIVIDE([Qty],t)

 

z2.PNG

 

Please downlaod attached .pbix file to have a look.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
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

1 REPLY 1
v-qiuyu-msft
Community Support
Community Support

Hi @Avi,

 

You can create a table like below:

 

Table 2 = SUMMARIZE('Table1','Table1'[Customer],"Total",SUM(Table1[Quantity]))

 

Then create two measures below:

 

Qty = var MA=CALCULATE(MAX('Table 2'[Total]),ALL('Table 2'))
var Mi=CALCULATE(Min('Table 2'[Total]),ALL('Table 2'))
Return
IF(MAX('Table 2'[Total])=MA || MAX('Table 2'[Customer])="D",SUM('Table 2'[Total]),CALCULATE(SUM('Table 2'[Total]),ALL('Table 2'))-MA-Mi )

 

Qty% = var t=CALCULATE(SUM('Table 2'[Total]),ALL('Table 2'))
return 
DIVIDE([Qty],t)

 

z2.PNG

 

Please downlaod attached .pbix file to have a look.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Solution Authors
Top Kudoed Authors