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
zibster
Helper III
Helper III

RANKX not working correctly

Hi,

I am using power pivot and trying to implemant rankx but i dont know why it is not working, I need to rank column Key for each Facility [Fac] at this point all I get is number 1 for all. Please help and Thansk

 

my current formula is:

=RANKX(ALL(Inv2018T),Inv2018T[FAC],[Key])

 

and here is the sample of my data

Capture.JPG

1 ACCEPTED SOLUTION
Michiel
Resolver III
Resolver III

RANKX doesn't understand that you mean to take [Key] from the table in which you create this column, and not from the ALL(inv2018T) which is the first argument to the function. Try it with EARLIER([Key]).

Or alternatively, use a variable:

=VAR ThisKey = [Key] RETURN RANKX(ALL(Inv2018T),Inv2018T[FAC],ThisKey)

View solution in original post

4 REPLIES 4
Michiel
Resolver III
Resolver III

RANKX doesn't understand that you mean to take [Key] from the table in which you create this column, and not from the ALL(inv2018T) which is the first argument to the function. Try it with EARLIER([Key]).

Or alternatively, use a variable:

=VAR ThisKey = [Key] RETURN RANKX(ALL(Inv2018T),Inv2018T[FAC],ThisKey)

Hi Michiel, Thanks for advice but when I use the formula you provided I am still getting 1 on all rows.

 

Thanks

Z

Oh, I'm being to quick here. Your RANKX function returns the rank of [Key] (when using EARLIER that is) among all values of [Fac]. Looking at your data, [Key] has much larger values than [Fac] and this means that it will probably always come out on top, so 1.

If you need the rank of [Key] among all rows with the same [Fac], you'll need to provide only the rows with the same [Fac] to RANKX. Like this:

= VAR ThisFac = [Fac]
RETURN
RANKX(FILTER(Inv2018T, Inv2018T[Fac] = ThisFac), Inv2018T[Key])

Perfect Thanks for your help Michiel

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.

Top Solution Authors