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
joyhackett
Helper II
Helper II

Percentile Rank in Group

Hi,

 

I've been looking at the other posts for Percentiles, but I am not finding a similar scenario, so I'd appreciate any guidance.

 

I have a fact table with Category, Subcategory, Item, and Count. 

 

There is an Item dimension table but it is NOT RELATED to the fact table.

 

The user must select a Item from a slicer (using the Item dimension table) and a card will show it's subcategory percentile rank.

 

joyhackett_0-1628091126021.png

 

Can anyone help with the Percentile Rank measure DAX?

 

Thanks!

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @joyhackett 

 

You can create two calculated columns in the table and then a measure to get the percentile value.

Two columns are:

Subcategory Rank = 
RANKX (
    FILTER (
        'Table',
        'Table'[Subcategory] = EARLIER ( 'Table'[Subcategory] )
    ),
    'Table'[Count],
    , // leave value argument blank
    DESC
)
PercentileRank = 
VAR _total =
    COUNTROWS (
        FILTER ( 'Table', 'Table'[Subcategory] = EARLIER ( 'Table'[Subcategory] ) )
    )
RETURN
    DIVIDE ( _total + 1 - 'Table'[Subcategory Rank], _total + 1 )

Measure:

Percentile = 
MAXX (
    FILTER ( ALL ( 'Table' ), 'Table'[Item] = SELECTEDVALUE ( 'Item List'[Item] ) ),
    'Table'[PercentileRank]
)

081001.jpg

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @joyhackett 

 

You can create two calculated columns in the table and then a measure to get the percentile value.

Two columns are:

Subcategory Rank = 
RANKX (
    FILTER (
        'Table',
        'Table'[Subcategory] = EARLIER ( 'Table'[Subcategory] )
    ),
    'Table'[Count],
    , // leave value argument blank
    DESC
)
PercentileRank = 
VAR _total =
    COUNTROWS (
        FILTER ( 'Table', 'Table'[Subcategory] = EARLIER ( 'Table'[Subcategory] ) )
    )
RETURN
    DIVIDE ( _total + 1 - 'Table'[Subcategory Rank], _total + 1 )

Measure:

Percentile = 
MAXX (
    FILTER ( ALL ( 'Table' ), 'Table'[Item] = SELECTEDVALUE ( 'Item List'[Item] ) ),
    'Table'[PercentileRank]
)

081001.jpg

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

Greg_Deckler
Super User
Super User

@joyhackett See this: (1) Solved: PERCENTRANK (Inclusive) - Microsoft Power BI Community

Also, see this:

Excel to DAX Translation - Microsoft Power BI Community

 


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

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.