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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
gspollock
Helper I
Helper I

RANX gives duplicates and skips numbers when filter is applied

I am requesting assistance on a report that is supposed to rank the Sales data. There is a slicer on the SECONDARY column.  When SECONDARY = N, the data has only one row for each CUST NUM/CUSTOMER combination.  When SECONDARY = Y is included in the data, there are multiple rows for each CUST NUM/CUSTOMER combination.

 

The RANKX seems to work correctly when SECONDARY = N. When either Y or both Y and N are selected in the slicer, it is giving duplicates for some rows that aren't identical and skipping some ranks.

 

This is the function: Rank Current = RANKX( ALLSELECTED(DIM_CUSTOMER[CUST NUM], DIM_CUSTOMER[CUSTOMER]), FACT_SALES[SALES],,DESC,Dense) 

 

Here is a portion of the underlying data.  

CUST NUMCUSTOMERACCOUNT MANAGERSECONDARYSALES
390429Customer11Account Manager10Y774933
390429Customer11Account Manager11Y774933
390429Customer11Account Manager4Y774933
575835Customer21Account Manager4Y671194
575835Customer21Account Manager3Y671194
575835Customer21Account Manager11Y671194
575835Customer21Account Manager6Y671194
575850Customer18Account Manager11Y877050
575850Customer18Account Manager6Y873142
575850Customer18Account Manager3Y877050
575850Customer18Account Manager4Y873142
733216Customer3Account Manager11Y420072
733216Customer3Account Manager5Y420072
733216Customer3Account Manager4Y420072
2158124Customer19Account Manager10Y308942
2158124Customer19Account Manager11Y308942
2158124Customer19Account Manager4Y308942
2491218Customer4Account Manager4Y450020
2491218Customer4Account Manager3Y900040
2491218Customer4Account Manager11Y450020
3751962Customer17Account Manager5Y2742127
3751962Customer17Account Manager4Y2742127
3751962Customer17Account Manager11Y2742127
3832376Customer7Account Manager2Y480377
3832376Customer7Account Manager10Y480377
3832376Customer7Account Manager4Y480377
3832376Customer7Account Manager16N480377
3832376Customer7Account Manager11Y480377
3832376Customer7Account Manager13Y480377

 

Thanks for your assistance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi lbendlin ,thanks for the quick reply, I'll add more.

Hi @gspollock ,

Try this

 

Measure = SUM('Table'[SALES])
Measure2 = RANKX(ALLSELECTED('Table'[CUST NUM],'Table'[CUSTOMER],'Table'[ACCOUNT MANAGER],'Table'[SECONDARY]),[Measure],,DESC,Dense)

 

 

Final output

vzhouwenmsft_0-1727081447455.png

vzhouwenmsft_1-1727081461720.png

Best Regards,
Wenbin Zhou

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi lbendlin ,thanks for the quick reply, I'll add more.

Hi @gspollock ,

Try this

 

Measure = SUM('Table'[SALES])
Measure2 = RANKX(ALLSELECTED('Table'[CUST NUM],'Table'[CUSTOMER],'Table'[ACCOUNT MANAGER],'Table'[SECONDARY]),[Measure],,DESC,Dense)

 

 

Final output

vzhouwenmsft_0-1727081447455.png

vzhouwenmsft_1-1727081461720.png

Best Regards,
Wenbin Zhou

lbendlin
Super User
Super User

Please follow this article

 

Use of RANKX in Power BI measures - SQLBI

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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