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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Asad_S
New Member

Help with RankX

I have two connected tables, one contains Item information (Numbers, description, price, cost etc) and the other is the item ledger which tracks quantities sold by Item numbers. They are connected using Item Number (Item Infomation Table) as a 1  to Many (Item ledger) relationship. 

 

I am able to put together tables that give me sales by Item number, one way is to use a calculated measure (quantity x price), and the other is by bringing in the price from the Item table into the Item ledger via look up and in the table multiply the price times the quantity. 

 

I am now trying to use RankX to Rank the Item Numbers by Total Sales and I can't get the function to work correctly. 

 

RankX formulas : 

 
Rank = RANKX(ALL('Item Table'[Item Number]),[Total Sales],,DESC) using the Calculated Measure Mentioned Above the first This Rank formula gives me a rank of 1, 2 and 3. (see snippet below)
 
Rank 2 = RANKX(ALL('Item Table'[Item Number]), SUM('Item Ledger Combined'[Gross Sales]),,DESC) using the Calculated Column in the item table mentioned above.  and the rank 2 formula only gives me a value of 1 for all rows. See Snippet Below.
 
 
Clearly, both of these are not calculating rank correctly. Any insight into how this can be done correctly would be appreciated as i'll need to replicate the rankx by quantity and cost as well. 
 

 

Asad_S_1-1692720051717.png

 

 

1 REPLY 1
Mahesh0016
Super User
Super User

@Asad_S Please can share your expected out and data table?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.