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

Trying to rank a column within filtered range in a flat file

Hi, I have a data file like this:

ZipcodeLabelValue
12222Label 112
12222Label 220
11111Label 15
11111Label 289

 

 

 

What I need is a rank column whichh rankes the labels based on Value WITHIN ALL THE SELECTED (FILETERED ) zipcodes.

ZipcodeLabelValueRank
12222Label 1121
12222Label 2202
11111Label 151`
11111Label 2892

 

This below line work properly ONLY FOR ONE ZIPCODE and is obviosuly static:

rank= rankx (FILTER ( ALL('table'), 'table'[zipcode] =("12222")), [value])

 

I want the same action but for EVERY SELECTED (FILTERED ) zipcode. So I went with this: 

 

rank= rankx (FILTER ( ALL('table'), ISFILTERED('table'[zipcode]),  [value])

 

 But it did not work.  It produces the number of selected zipcodes as the rank for every label. 

 

Thanks 

 

 

 

 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

You can create a measure as below to get the rank changed dynamically base on slicer selections, please find the details in the attachment.

 

Rank =
RANKX (
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[Zipcode] = SELECTEDVALUE ( 'Table'[Zipcode] )
    ),
    CALCULATE ( SUM ( 'Table'[Value] ) ),
    ,
    ASC,
    DENSE
)

 

yingyinr_0-1649744981110.png

If the above one can't help you get the desired result, please provide some sample data in the table (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

How to upload PBI in Community

Best Regards

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

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

You can create a measure as below to get the rank changed dynamically base on slicer selections, please find the details in the attachment.

 

Rank =
RANKX (
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[Zipcode] = SELECTEDVALUE ( 'Table'[Zipcode] )
    ),
    CALCULATE ( SUM ( 'Table'[Value] ) ),
    ,
    ASC,
    DENSE
)

 

yingyinr_0-1649744981110.png

If the above one can't help you get the desired result, please provide some sample data in the table (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

How to upload PBI in Community

Best Regards

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

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.