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

Win a FREE 3 Day Ticket to FabCon Vienna. Apply now

Reply
LinhNguyen
Helper II
Helper II

RANKX starts at 2 instead of 1

my dax function for reverse rank is: 

ReverseRank = RANKX(all('Data by selections'[Selected Item]),[Rank],,DESC,Dense)
with data as in the table below, the ranks started at 2 instead of 1. I saw a few others having the same issue but none was solved.
Can anyone help me with this? I also tried ALLSELECTED but that didn't work out either.
Thanks

 

SelectionSelected ItemCount of SessionsRankReverseRank
Edge Connect Bottom2D Webcam162
Edge Connect BottomNew 2D Barcode Scanner162
Edge Connect BottomSmall EMV Cradle162
Edge Connect Bottom3D Camera253
Edge Connect BottomMSR344
Edge Connect BottomFingerprint Scanner535
Edge Connect BottomNFC926
Edge Connect BottomStatus Light926
Edge Connect Bottom2D Barcode Scanner5917
5 REPLIES 5
amitchandak
Super User
Super User

@wdx223_Daniel ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
amitchandak
Super User
Super User

@LinhNguyen ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
LinhNguyen
Helper II
Helper II

Hi @wdx223_Daniel , @amitchandak 

 

All of these columns come from the same data table so there should not be any empty row created because of relationships with other tables. I have checked the table this data comes from and there's no blank or empty. 

The formula I used for Rank is very similar to Daniel's: 

Rank = RANKX(all('Data by selections'[Selected Item]),calculate(count('Data by selections'[SessionID])),,DESC,Dense)
but when I added the 'ALLEXEPT()' part into CALCULATE, the rank started from 32.
Is there anything else this might imply? Anything I can try next to determine what the problem is?
amitchandak
Super User
Super User

@LinhNguyen , I tried on data given I am getting correct Rank. make sure if you are using a formaul(not measure) in rank then use calculate

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
wdx223_Daniel
Super User
Super User

use the sample data and code as below, i did not catch that error, all result are normal

wdx223_Daniel_0-1604537388547.png

Rank:=RANKX(ALL(DataBySelections[Selected Item]),CALCULATE(SUM(DataBySelections[Count of Sessions]),ALLEXCEPT(DataBySelections,DataBySelections[Selected Item])),,DESC,Dense)
*****************************
ReverseRank:=RANKX(ALL(DataBySelections[Selected Item]),[Rank],,DESC,Dense)

i guess you might got a blank item based on a invalid relationship.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.