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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Rankx with ASC starting rank at 2

Hello Experts ,

Rankx fx with ASC is starting at 2  any reason ?  

With DESC woking fine ..

Here is my logic 

Rank Overtime = Rankx(allselected('VCS VCS Mapping'[FACILITY]),[mm], ,ASC,Dense)
Ave OverTime = SUM('VCS OverTime'[Total Hours]) / SUM('VCS OverTime'[OT Hours])
Rank is applied on Ave Over time . TIA
 

 

Anjali_mm_0-1641248666471.png

 

2 ACCEPTED SOLUTIONS
OwenAuger
Super User
Super User

Hi @Anonymous 

Try this instead:

 

Rank Overtime =
RANKX (
    CALCULATETABLE ( VALUES ( 'VCS VCS Mapping'[FACILITY] ), ALLSELECTED () ),
    [Ave OverTime],
    ,
    ASC,
    DENSE
)

 

In your original measure, ALLSELECTED( .... ) returns all values of FACILITY in the overall filter context of the visual, not taking into account any cross filtering from filters such as REGION.

 

For any facilities that don't exist in the context of the other filters applied (e.g. Facilities not in the Central region), [Ave OverTime] is therefore blank (equivalent to zero for the purpose of RANKX), and they are tied with rank 1.

 

The change I made above changes the first argument of RANKX to include only Facilities that exist in the overall filter context of the visual.

 

Does this work for you?

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

ValtteriN
Super User
Super User

Hi,

This behaviour is likely caused by your ALLSELECTED referencing a column. When this column is blank and filtered RANKXX faces issues. Here I recreated the issue:

ValtteriN_0-1641250725323.png


In this example I refrer to the table instead of the column:

ValtteriN_1-1641250776707.png

 

So as a solution you could refer to the table. I hope this helps and if it does consider accepting this as a solution and giving the post a thumbs up!






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

6 REPLIES 6
ValtteriN
Super User
Super User

Hi,

This behaviour is likely caused by your ALLSELECTED referencing a column. When this column is blank and filtered RANKXX faces issues. Here I recreated the issue:

ValtteriN_0-1641250725323.png


In this example I refrer to the table instead of the column:

ValtteriN_1-1641250776707.png

 

So as a solution you could refer to the table. I hope this helps and if it does consider accepting this as a solution and giving the post a thumbs up!






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




OwenAuger
Super User
Super User

Hi @Anonymous 

Try this instead:

 

Rank Overtime =
RANKX (
    CALCULATETABLE ( VALUES ( 'VCS VCS Mapping'[FACILITY] ), ALLSELECTED () ),
    [Ave OverTime],
    ,
    ASC,
    DENSE
)

 

In your original measure, ALLSELECTED( .... ) returns all values of FACILITY in the overall filter context of the visual, not taking into account any cross filtering from filters such as REGION.

 

For any facilities that don't exist in the context of the other filters applied (e.g. Facilities not in the Central region), [Ave OverTime] is therefore blank (equivalent to zero for the purpose of RANKX), and they are tied with rank 1.

 

The change I made above changes the first argument of RANKX to include only Facilities that exist in the overall filter context of the visual.

 

Does this work for you?

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn
Anonymous
Not applicable

THANK YOU for your effort.

I have a Question 

What if My Visual Was a card ? I think ALLSELECTED is not the right choice for this situation.

Anonymous
Not applicable

Hey @OwenAuger ,

How can I write same measure in Calculated column ?

I see circular dependancy  while using CC...

 

Thanks for your help

Hi there @Anonymous 

That formula is designed as a measure, so could well have unexpected results in a calculated column.

 

If you want a Rank in a calculated column, we would need to rewrite slightly, depending which table it's in.

 

Could you post a model diagram, or a santised PBIX?

 

Are you adding it to 'VCS VCS Mapping', and you want each FACILITY to have the same rank?

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn
Anonymous
Not applicable

Here is sample data @OwenAuger 

Rank by facility based on Ave values (Vacancy, SMS, Tenure).

Your solution was working fine but i need it in CC.

Thanks a LOT.

 

REGIONFACILITYVacancyTenureDatesms
USAStewart240005/1/202110
USAStewart5040007/1/202010
USAStewart5040009/1/202010
USAWhitehorse50400010/1/202010
USAWhitehorse50400011/1/202010
USAWhitehorse50400012/1/202010
USAWhitehorse30202/1/202132.22
USAWhitehorse30205/1/202132.22
USAAp30207/1/202032.22
CANADAMarket30209/1/202032.22
CANADAMarket302010/1/202032.22
CANADAMarket302011/1/202032.22
CANADAMoon22012/1/202032.22
CANADAMoon2203/1/202132.22
CANADAMoon23405/1/20213.43
CANADAMoon23406/1/20213.43
CANADAWest Lane53407/1/20203.43
CANADAWest Lane53408/1/20203.43
CANADAWest Lane53409/1/20203.43
CANADAWest Lane534010/1/20203.43
SAWoods534012/1/20203.43
SAWoods5502/1/20213.43
SAWoods5503/1/20213.43
SASHOP789504/1/20213.43
SASHOP789506/1/20213.43
SASHOP789509/1/20203.43
SASHOP7895010/1/20203.43
SABedford7895011/1/20203.43
SABedford7895012/1/20203.43
SABedford789502/1/20213.43

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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