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
ViktorT
Frequent Visitor

DAX Rankx function returning only 1

Hi

 

I have encountered some problems with the rankx function. I will try to explain it in as much detail as possible.

 

Two tables; orders & products:

 

Diagram viewDiagram viewOrders tableOrders tableProduct tableProduct table

I have constructed measurements as follows:

 

     Total order value:=sumx(Orders;Orders[Qty]*RELATED(Products[Price]))

 

     RankOrder:=rankx(All(Orders);[Total order value])      <= is working

     RankProd:=rankx(All(Products);[Total order value])    <= is not working

 

I tested the formulas in power pivot to present it in a pivot table as per below. As you can see, the rank on items/products is not working properly. Only returning rank 1 for all. I assume this have something to do with the relationships or something, but cannot find out how to solve it.

ResultResult

Any insights would be helpful. Thanks in advance.

best regards

Viktor

 

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @ViktorT 

In you pivot table on the right, place Products[ItemID] on the rows instead of Orders[ItemID]

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

 

View solution in original post

2 REPLIES 2
AlB
Community Champion
Community Champion

Hi @ViktorT 

In you pivot table on the right, place Products[ItemID] on the rows instead of Orders[ItemID]

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

 

ViktorT
Frequent Visitor

@AlBthanks alot for your quick reply. Such an irritatingly simple solution 😃

I guess the conclusion is to take care of from which table the ranking value originates from when presenting the data, regardless which table you put the measurement.

cheers

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.