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
Supakit_1
Regular Visitor

Rankx in measure

 
 

I would like to making index key for my product in table visualization. My table look like this

 

UniqProductIDProductName
156A
156A
964B
789C
789C

 

I using this dax in my measure

 

index = RANKX(
tblProduct ,MAX(tblProduct [UniqProductID]),,ASC,Dense
)
 
index is alway show as "1" .
 
I would like to show result like this.
 
 Filter : A,B,C
 
IndexUniqProductIDProductName
1156A
1156A
2964B
3789C
3789C

 

Filter : A,C
 
IndexUniqProductIDProductName
1156A
1156A
2789C
2789C

 

So, Index field will be dynamic per filter selection. How to write dax as per expected result.

 

Thank you.

 

 

 

2 REPLIES 2
VahidDM
Super User
Super User

EDITED

Hi @Supakit_1 

 

Try this measure:

 

 

index = 
RANKX (
    ALLSELECTED ( tblProduct ),
    CALCULATE (
        MAX ( tblProduct[ProductName] ),
        ALLEXCEPT ( tblProduct, tblProduct[ProductName] )
    ),
    ,
    ASC,
    DENSE
)

 

 

Output:

 

 

VahidDM_2-1631069802756.png

VahidDM_3-1631069816240.png

 

 

 

You can also download the file: https://gofile.io/d/4JJQpK

 

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

Appreciate your Kudos✌️!!

 

wdx223_Daniel
Super User
Super User

index = RANKX(
tblProduct ,calculate(MAX(tblProduct [UniqProductID]),ALLEXCEPT(tblProduct,tblProduct [UniqProductID])),,ASC,Dense
)

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.

Top Solution Authors