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
Moonc
Frequent Visitor

RANKX Issues with 0s

I want my rank to start at 0 and go from there. Currently it is ranking my 0 values and the next lowest value as 1 and then ranking

=RANKX(FILTER(ALLSELECTED( [Program]), [NUMBER] ), [NUMBER],,ASC)

[Number] is a measure that is summing a value with some other conditions present

Expected Result

Program Number Rank

A1515
B2356
C1234
D01
E122
F553

Actual Result

Program Number Rank

A1515
B2356
C1234
D01
E121
F553

0 and the next lowest value are both getting ranked 1, which will not work for what I am trying to do.

 

I tried putting SUMX() around [NUMBER] in the ALLSELECTED, while that does work when the data is on its own, it breaks when I have to put the entire formula together (Two separate ranks for a matrix using ISINSCOPE() to change which rank is being applied)

 

I also tried setting the rank of 0 to 1 and then ranking +1. While this works for instances that there is one 0 present, if there are multiple 0s, I need the rank to skip. So both the 0s would be ranked 1 and then the next lowest value would be ranked 2, when I need it to be rank 3.

 

Any idea? I feel like I am not understanding something as the rank should just be applied to how the values are presented...

4 REPLIES 4
FreemanZ
Super User
Super User

hi @Moonc 

how about:

=RANKX(ALLSELECTED( [Program]), [NUMBER],,ASC)

@FreemanZ That works for when I am not working in a matrix. I should have made this more clear. I have a matrix with both program and subprogram, and I need to have a rank for each. So the formula that I am actullay using looks like the below

 

RANK = 

VAR _program = RANKX(ALLSELECTED( [Program]), [NUMBER],,ASC)

VAR _subProgram = RANKX(ALLSELECTED( [subProgram]), [NUMBER],,ASC)

 

RETURN

if(isinscope(program),_program,if(isinscope(subProgram),_subProgram))

 

This returns a proper rank for the program, but the subProgram has all the same rank

@Moonc , if both are on row and program is first and sub program is second then try like

 

RANK =

VAR _program = RANKX(ALLSELECTED( [Program]), [NUMBER],,ASC)

VAR _subProgram = RANKX(ALLSELECTED( [subProgram]), [NUMBER],,ASC)

Switch (True()

isinscope(subProgram,_subProgram,

isinscope(program),_program

)

 

The first one or the parent is always isinscope for the child 

 

IsInScope - Switch Rank at different levels: https://youtu.be/kh0gezKICEM

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak This does not work, I am seeing the program ranks correct, but the subprogram ranks are incorrect. I don't see any pattern in the rank that would help me understand.

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!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.