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
apohl1
Helper I
Helper I

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 I
Helper I

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