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
PBI_Michael
Frequent Visitor

Percentile as a measure

Hi, I calculated the ranking of a data set using this DAX expression: 

 

Rank = if(not(ISBLANK([Avg Value1])), RANKX(ALLSELECTED('Table1'[ProductID]), [Avg Value1], , DESC, Dense), Blank())

 

which returns the ranking of all products by average Measure1, now my problem is that the ranking is a measure, not a column, I made it this way because I need the ranking to be dynamic and adapt as filters and slicers are applied to the report.

 

I saw a solution similar to my problem here: https://community.powerbi.com/t5/Desktop/PERCENTRANK-Inclusive/m-p/81208 

 

But that solution applies to columns as they use the countA function : 

 

Image 1.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

So, my question is how can I get the same result using my measure and not creating columns? 

 

Thanks in advance

 

 

 

 

4 REPLIES 4
vazfelipe
Frequent Visitor

Hi, 

 

Im reactivating this one trying to get related answers about PERCENTILE in DAX 2013 version. 

 

If I have a table with categories (A, B, C) and it has a column of values, how can I get a PERCENTILE 80% for each category as a measure, not column?

 

Please, I have tried a lot, cos there's no PERCENTILE.INC as a function in 2013 version.

v-yulgu-msft
Employee
Employee

Hi @PBI_Michael,

 

 

You can try below measures:

Rank =
IF (
    NOT ( ISBLANK ( [Avg Value1] ) ),
    RANKX ( ALLSELECTED ( Percentile[ProductID] ), [Avg Value1],, DESC, DENSE ),
    BLANK ()
)

PctRank =
 ( COUNTAX ( ALLSELECTED ( Percentile ), Percentile[ProductID] ) - [Rank] )
    / ( COUNTAX ( ALLSELECTED ( Percentile ), Percentile[ProductID] ) - 1 )

 2.PNG

 

However, if your desired output is like this:

3.PNG

 

You need to relplace the ALLSELECTED function with ALL.

PctRank =
 ( COUNTAX ( ALL ( Percentile ), Percentile[ProductID] ) - [Rank] )
    / ( COUNTAX ( ALL ( Percentile ), Percentile[ProductID] ) - 1 )

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Juliana Thank you very much, I'm a bit confused by the use of the word Percentile in your solution which seems to be a table name, let me put an example of how the data is organized in my tables:

Image 1.jpg

 

I created the merged table because I needed to create a weighted average of the Value1 and Value2

 

so I used sumx to create a measure for the weighted average of value1 called: Avg Value1 in MergedProduct-DataTable

 

then used the RankX function as described to create a measure that returns a rank based on Avg Value1 

 

I think so far so good, now based on the way my data is organized, can you please re-write your formulas as I'm unsure what table names and columns should I use and can't understand the (Percentile[ProductID) and (Percentile) mean in this context.

 

Again thank you very much! 

 

 

 

 

 

Hi @PBI_Michael,

 

'Percentile' is the table name which you created measures based on. Percentile[ProductID] is the same as 'Table1'[ProductID] in the DAX formula you provided in your original post.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.