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

DAX Percentage of users based off a calculated column

Hello,

 

I have a list of a few thousand users that I want to group based off a calculated column.

I want to create the following: (note, each user has their own unique calculated column result)

  • Top 5% of users based off calculated column value
  • Top 6%-15% users based off calculated column value
  • Top 16%-51% users based off calculated column value
  • Remaining  users based off calculated column value

This user list will change monthly, so I want it to actually give me the top 5% no matter what.. not just a manual formula.

 

I attempted to use the switch formula, but I was only able to categorize the column based off of the numeric value.. and not the top % of users.  

 

Thanks in advance,

 

Ryan

 

1 ACCEPTED SOLUTION

See if this works for you as a calculated column:

 

Category = 
VAR __tmpTable = ALL(Table5)
VAR __95thPercentile = PERCENTILEX.EXC(__tmpTable,[Column],.95)
VAR __85thPercentile = PERCENTILEX.EXC(__tmpTable,[Column],.85)
VAR __49thPercentile = PERCENTILEX.EXC(__tmpTable,[Column],.49)
RETURN
    SWITCH(
        TRUE(),
        [Column]>=__95thPercentile,"5%",
        [Column]<__95thPercentile && [Column]>=__85thPercentile,"6% - 15%",
        [Column]<__85thPercentile && [Column]>=__49thPercentile,"16% - 51%",
        "50% and lower"
    )


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Seems like an interesting problem. Can you share sample data?

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Not sure how to add an attachment here... but this is essential it in ascending order.

UserList - names removedCalculated column
User864436.80313375
User1701335.60606396
User2050034.81004103
User1985032.3700428
User1778927.35574811
User2259127.30762131
User1648827.23835013
User1577025.9206543
User1605425.78695572
User1588425.29712316
User1599325.2695319
User1682424.80589433
User1656324.35537261
User1589424.33767634
User1773223.51984606
User1604523.4172969
User1080723.35994523
User2007622.87100228
User1589622.58415034
User1948521.83053828
User2113021.15677461
User1598321.13471259
User887120.72607361
User1587620.60984436
User1798720.41012125
User1622620.3500364
User1978419.90793115
User1753019.69572597
User1614619.06938297
User2293119.01623082
User1947018.6647573
User1674018.44771066
User1601018.41748009
User1592218.31152393
User1588118.2430582

and so on... all the way down to 25k users/rows.

 

I would like to find the top 5%, 6-15%, 16-51%, 50% and lower... of these 25k users based off of column B.  

 

Let me know if this makes sense.

 

Thanks,

 

Ryan

See if this works for you as a calculated column:

 

Category = 
VAR __tmpTable = ALL(Table5)
VAR __95thPercentile = PERCENTILEX.EXC(__tmpTable,[Column],.95)
VAR __85thPercentile = PERCENTILEX.EXC(__tmpTable,[Column],.85)
VAR __49thPercentile = PERCENTILEX.EXC(__tmpTable,[Column],.49)
RETURN
    SWITCH(
        TRUE(),
        [Column]>=__95thPercentile,"5%",
        [Column]<__95thPercentile && [Column]>=__85thPercentile,"6% - 15%",
        [Column]<__85thPercentile && [Column]>=__49thPercentile,"16% - 51%",
        "50% and lower"
    )


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Worked great!  Thank you very much Greg.

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.