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
Anonymous
Not applicable

Show percentile for single customer

Hi all, I currently have a Customer View report which gives the ability to filter on only 1 customer. I have the a KPI card showing the customer's revenue, but I want to be able to show that this customer is in the X percentile of customers in terms of revenue. How can I do in this view that given that I am only giving the end user the ability to filter on a single customer at a time for the entire report?

 

I'd want to have a slicer on the report for Customer, and when I select customer A, show that it is in the 33rd percentile of customers by revenue.

 

CustomerRevenue
A20
A30
B50
B60
C100
C120
11 REPLIES 11
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Has your problem been solved? If yes, please consider Accept it as the solution to help the other members find it more quickly.

 

Best regards,
Lionel Chen

v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Like this?

y3.PNG

 

Measure = 
VAR x = 
CALCULATE(
    SUM(Sheet1[Revenue]),
    ALL(Sheet1)
)
VAR y = 
CALCULATE(
    SUM(Sheet1[Revenue]),
    ALLEXCEPT(Sheet1, Sheet1[Customer])
)
RETURN
DIVIDE(
    y, x
)

 

Don’t you want the ratio of each customer ’s revenue to total revenue?

Maybe you can list the return values you want to get.

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi Lionel, no I want the Percentile of the customer in terms of revenue. If I had 10 customers, and used the report slicer to filter on a single customer and this customer's revenue was the highest out of any customer, I want it to show that this customer is in the 100th percentile of customers. If it was the 5th highest revenue customer, I want it to show that this customer is in the 50th percentile.

@Anonymous  This should give you percentile;

 

Percentile =
DIVIDE(RANKX(ALL(DimCustomer), SUMX(RELATEDTABLE(FactInternetSales),FactInternetSales[SalesAmount]),,ASC),COUNTROWS(ALL(DimCustomer)))
 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 


If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hi @Anonymous ,

 

Like this?

Sum of revenue = 
VAR x = 
CALCULATE(
    SUM(Sheet1[Revenue]),
    ALLEXCEPT(Sheet1, Sheet1[Customer])
)
RETURN
x
_Rank = 
RANKX(
    ALL(Sheet1),
    [Sum of revenue],
    , DESC, Dense
)
% = 
IF(
    [_Rank] > 1,
    [_Rank] * 0.1,
    [_Rank]
)

y4.PNG

 

If it is still wrong, please list the values of the desired results in a table.

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Try to do like this:

Measure 4 = 
VAR x = 
CALCULATE(
    SUM('Table'[Revenue]),
    ALL('Table')
)
VAR y = SELECTEDVALUE('Table'[Revenue])
RETURN
DIVIDE(
    y, x
)

x6.PNG

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

@v-lionel-msft , I think this gives me percent of total revenue. I have edited my original post to clarify. I am actually looking for the percentile among the customer base. So if Customer A had the lowest revenue out of the 4 customers, I want the number to show that it is in the 25th percentile of customer base in terms of revenue.

Anonymous
Not applicable

Hi @v-lionel-msft , thanks for the response. Var X is giving me total revenue like it should, but Var Y is giving me (blank). Do you know why this is?

@Anonymous  My guess for why y is zero would be that you have multiple revenue values for each customer and var y is set only to show the selectedvalue. SELECTEDVALUE in DAX has an optional second argument that gets returned if there is more than one value selected. Try using SUM instead of SELECTEDVALUE

 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

 

If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

@AllisonKennedy when I do that, the value turns to 0. I think the issue is that for Var X, which is supposed to be the denominator, once the slicer is applied for a customer then Var X turns the same as Var Y thus giving me a 0. I've updated my original post with example data, hope this clarifies my question.

AllisonKennedy
Super User
Super User

You will need to use the ALL() function inside a MEASURE. 

 

Create a MEASURE that has the calculation for percentile, and when you get to the bottom of the fraction, divide by

CALCULATE(bottom of fraction, ALL())

Or ALL(Customer) depending on if you want the other slicers on the report to affect the total that it divides by.

 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

 

If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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.