Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.