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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.

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.

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

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors