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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Imrans123
Advocate V
Advocate V

RANKX based on a DAX measure

Was wondering if anyone could help me. I have a DAX measure that calculates total sales from my raw data.

 

My billings data also has relationship with my customer table so I can see total sales by customer. I want to create a Rank measure within this visual to show ranking by customer. However, the RANKX measure only allows me to use a column as value.

 

i.e. RANKX(ALL('Customer'[Customer ID],[column ref here]))

 

Was wondering if there was a way to use DAX measure and not a column or calculated column to do the RANKX measure. If not, whether there is an alternate way to create a ranking measure?

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @Imrans123 ,

I have listed three common cases according to your dax, 1, normal sorting 2, group sorting 3, summary sorting, the following pbix contains the columns for these three kinds of sorting, and the MEASURE, you can refer to my file and adjust it according to your environment.

1.test1 and test11  normal sorting 

2.test2 and test22  group sorting

3.test3 and test33  summary sorting

vluwangmsft_0-1648002553667.png

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


Best Regards

Lucien

View solution in original post

6 REPLIES 6
v-luwang-msft
Community Support
Community Support

Hi @Imrans123 ,

I have listed three common cases according to your dax, 1, normal sorting 2, group sorting 3, summary sorting, the following pbix contains the columns for these three kinds of sorting, and the MEASURE, you can refer to my file and adjust it according to your environment.

1.test1 and test11  normal sorting 

2.test2 and test22  group sorting

3.test3 and test33  summary sorting

vluwangmsft_0-1648002553667.png

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


Best Regards

Lucien

Whitewater100
Solution Sage
Solution Sage

Hi:

You can use:

RANKX(

CALCULATETABLE(

SUMMARIZE(

'Sales',

 

 Customers[Name]

 ),

 ALL(Customers[Name])),

 [Total Sales], , DESC)

Thanks a lot. A little confused, was wondering if you could explain

 

So if I understand correctly, SUMMARIZE('Sales', Customers[Name]...

 

Shouln't be group by from the Customer table? i.e. Summarize('Customers','Customers'[Name]...

I'll try writing with your columns in mind

RANKX(

CALCULATETABLE(

SUMMARIZE(

'Billings',

 

 Customers[ID]

 ),

 ALL(Customers[ID])),

 [Total Sales], , DESC)

Hi:

 

Yes Summarize(Billings[Customer ID]  I used Sales[Customer name] which may have thrown it off. Essentially, it will go thru all the sales records by customer (a virtual table) to determine the ranking for each customer.

 

aj1973
Community Champion
Community Champion

Hi @Imrans123 

You can use a virtual column or table into a Variable nested into a measure.

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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