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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
minnie_1
New Member

RANKX returns 1 for all ISO Codes

 

Test Ranking2 = 

var test = Table[Slicer] 

var NumericValue =IF( CONTAINSSTRING(test, "%"), VALUE(SUBSTITUTE(test, "%", "")), IF (CONTAINSSTRING(test, "$"), VALUE(SUBSTITUTE(test, "$", "")), BLANK() )) 

return 

RANKX(FILTER(ALL(Table[IsoCode]), NumericValue), NumericValue,,ASC)

 

I want to rank ISO Code column based on value in Slicer. Slicer has both % and $ values based on selected column, so I created NumericValue variable to convert all values to type number and remove % or $ for calculation. My $ values are based on Sum of column grouped by ISO Code and % are based on Average of column grouped by ISO Code. 


I tried different forms in expression field like :
1. returns 1 for all ISO Codes

 

MAXX(WinLossDataWithCountry,NumericValue) ​

2. returns different numbers with duplicate ranking but giving value 10000 and 400 same rank. So its wrong

 

 

SUMX(WinLossDataWithCountry,NumericValue) ​

 

 

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but can you try something like below if it works?

 

Test Ranking2 =
VAR test = Table[Slicer]
RETURN
    RANKX (
        ALL ( Table[IsoCode] ),
        CALCULATE (
            IF (
                CONTAINSSTRING ( test, "%" ),
                VALUE ( SUBSTITUTE ( test, "%", "" ) ),
                IF (
                    CONTAINSSTRING ( test, "$" ),
                    VALUE ( SUBSTITUTE ( test, "$", "" ) ),
                    BLANK ()
                )
            )
        ),
        ,
        ASC
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.