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

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

Reply
apohl1
Helper II
Helper II

Optimize RANKX and CUMULATIVE total to segment customers as top 80% and bottom 20%

Hi PBI experts,

 

I am working on an analysis where I want to segment customers based on their opportunity. My aproach is summarized below. The approach works but performance is bad. I'm posting my formulas below, if anyone has an idea how to improve the formulas it would be highly appreciated! If anyone has a different idea how to the analysis with a different approach that's also super welcome! Thanks in advance!


The approach:

1. Rank the customers based on opportunity amount

2. Create cumulative total based on customer rank

3. Segment customers into 2 groups based on their cumulative total ("top 80%" anf "bottom 20" customers")

 

The measures:

  • Opportunity rank =
var blanks = ISBLANK(sum('Procedure volumes'[Opportunity]))||sum('Procedure volumes'[Opportunity])=0
RETURN
SWITCH(
TRUE(),blanks,BLANK(),
RANKX(ALLSELECTED('C Account'[C. Account Name]),CALCULATE(sum('Procedure volumes'[Opportunity])),,DESC,Skip))

 

  • Cumulative =
var currentRank = [Opportunity rank]
var blanks = ISBLANK('Procedure volumes'[Opportunity rank])||sum('Procedure volumes'[Opportunity])=0
RETURN
SWITCH(
TRUE(),
blanks,BLANK(),
SUMX(FILTER(ALLSELECTED('C Account'[C. Account Name]), [Opportunity rank]<=currentRank ), CALCULATE(sum('Procedure volumes'[Opportunity]))))
 
  • Customer classification =
VAR topPercentage = 0.8
VAR totalMargin = CALCULATE(sum('Procedure volumes'[Opportunity]), ALLSELECTED('C Account'[C. Account Name]))
VAR topRankNumber = MAXX(FILTER(ALLSELECTED('C Account'[C. Account Name]), [Cumulative]<= totalMargin* topPercentage), [Opportunity rank] )
RETURN
IF(ISBLANK([Opportunity rank]) || ISBLANK(sum('Procedure volumes'[Opportunity])), BLANK(),
IF( [Opportunity rank]<=topRankNumber,"Top 80%","Bottom 20%"))
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@apohl1 , Refer this blog- I doubt you need rank, check if this can help

 

https://exceleratorbi.com.au/pareto-analysis-in-power-bi/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
apohl1
Helper II
Helper II

Thanks so much @amitchandak, it works perfectly!!

amitchandak
Super User
Super User

@apohl1 , Refer this blog- I doubt you need rank, check if this can help

 

https://exceleratorbi.com.au/pareto-analysis-in-power-bi/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
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.