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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PowerBI_Account
Frequent Visitor

Calculate average per 20% bins based on ranking

Hi all,

 

I've got the following data:

 

Customer NumberScore (1-100)Ranking (as a measure)
1951
2226
3365
4573
5118
629
7882
8474
9157
10110

 

I want to create a funnel graph with the average score per 20% buckets based upon ranks like so:

 

BucketAverage Score
0-20%91.5
21-40%52
etcetc

 

 

How would I go about doing this? I was thinking along the following lines, but it wont work:

 

Score 0-20% =
CALCULATE ( AVERAGE ( Customer[Score] ), [Ranking] < 0.2 * ALL ( [Ranking] ) )
 
Thanks in advance!
1 ACCEPTED SOLUTION

Hi, @PowerBI_Account 

You can try measure as below:

Ranking = 
RANKX ( ALL ( Customer ), CALCULATE ( MAX ( Customer[Score] ) ),, DESC, DENSE )
M_Score 0-20% = 
VAR a =
    ROUNDDOWN ( 0.2 * MAXX ( ALL ( Customer ), [M_Ranking] ), 0 )
RETURN
    CALCULATE ( AVERAGE ( Customer[Score] ), FILTER ( Customer, [M_Ranking] <= a ) )

10.png

Please check my sample file for more details.

 

Best Regards,
Community Support Team _ Eason

 

View solution in original post

3 REPLIES 3
PowerBI_Account
Frequent Visitor

I also tried the following, but the MAXX() just returns 1:

 

Score 0-20% =
var highestRank = CALCULATE(MAXX(Customer, [Ranking]), NOT(ISBLANK(Customer[Score])))
RETURN
CALCULATE(AVERAGE(Customer[Score]), [Ranking] < 0.2*highestRank))
 

Hi, @PowerBI_Account 

You can try measure as below:

Ranking = 
RANKX ( ALL ( Customer ), CALCULATE ( MAX ( Customer[Score] ) ),, DESC, DENSE )
M_Score 0-20% = 
VAR a =
    ROUNDDOWN ( 0.2 * MAXX ( ALL ( Customer ), [M_Ranking] ), 0 )
RETURN
    CALCULATE ( AVERAGE ( Customer[Score] ), FILTER ( Customer, [M_Ranking] <= a ) )

10.png

Please check my sample file for more details.

 

Best Regards,
Community Support Team _ Eason

 

Thanks for the effort! Initial testing looks good, will test more in-depth later on in the week.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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