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
smore
Advocate I
Advocate I

DAX RANKX: Rank Column that ranks based on slicer selection?

Spoiler
 

I have a slicer based on Table[Color] and a ranking measure that ranks items based on Table[Size]. When all colors are selected in the slicer it ranks every item. When a specific color is selected, it ranks only the items for that color starting from 1. This is exactly what I need. My problem using the Rank Measure is that Power BI will not let me use the Rank Measure as an axis in my visuals.

I know that I can use a calculated column as an axis for the visuals. So to work around the original problem, I tried to create a calculated column (Rank Column) that copies the Rank Measure. The calculated column works in ranking all items but when using the slicer, it does not rank items starting from 1, it just gives their overall rank based on all colors. How can I get the Calculated Column to rank starting from 1 based on the slicer selection?

Below is the DAX for the Rank Measure and Rank Column.
_____________________

Rank Measure =
RANKX(
ALLSELECTED('Table'),
CALCULATE(SUM('Table'[Size]))
,, DESC
)
______________________

 

Rank Column = 
RANKX(
         ALLSELECTED('Table'),
         CALCULATE(
                SUM('Table'[Size]),
                AllEXCEPT('Table', 'Table'[Size])
          )
          ,, DESC
)
______________________



1 ACCEPTED SOLUTION
v-xulin-mstf
Community Support
Community Support

Hi @smore,

 

Do you want to show the overall ranking after applying the slicer?

Here is the output:

v-xulin-mstf_0-1616479655130.png

Try measure as:

Rank Measure = 
RANKX(
    ALL('Table'),
    CALCULATE(SUM('Table'[Size]))
    ,, DESC
)

 

Best Regards,

Link

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
v-xulin-mstf
Community Support
Community Support

Hi @smore,

 

Do you want to show the overall ranking after applying the slicer?

Here is the output:

v-xulin-mstf_0-1616479655130.png

Try measure as:

Rank Measure = 
RANKX(
    ALL('Table'),
    CALCULATE(SUM('Table'[Size]))
    ,, DESC
)

 

Best Regards,

Link

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@smore ,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

I am not sure how to upload a pbix on the forum so here is a google drive link to a sample.pbix:

https://drive.google.com/file/d/1EeEjuF9_iQCPQIEeS7bZVKmOIii8GqEE/view?usp=sharing

After preparing the sample pbix I realized that the Rank Column is not ranking properly. I am not sure what is wrong with the DAX code for the Rank Column. I just want it to work the same as the Rank Measure. Thanks for your reply.

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.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors