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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
khappersett
Resolver I
Resolver I

RANKX Function to Rank Table by Revenue

I am having trouble getting my rankx function to work. I have visited so many threads with similar questions but still can't seem to figure it out.

 

I have a table with product skus, item IDs, revenue amounts, etc. and want to rank them based on the revenue amount (item with the highest revenue will have a ranking of 1).

 

Here is my code, but I have tried so many variations of this (without sum, without calculate, without both, without DESC, without [sku], etc.)

 

Rank = rankx(ALL('PH FY 2016'[sku]),CALCULATE(SUM('PH FY 2016'[Net Revenue])),,DESC)

The table won't load with this current code, and the closest I've gotten has returned all 1s. Any help is much appreciated!

1 ACCEPTED SOLUTION

I got it working with this code:

 

Rank = rankx(ALLSELECTED('PH FY 2016'[sku]),CALCULATE(SUM('PH FY 2016'[Net Revenue]), ALLEXCEPT('PH FY 2016','PH FY 2016'[sku], 'Cat DICT'[Category])))

View solution in original post

4 REPLIES 4
Vvelarde
Community Champion
Community Champion

@khappersett

 

If you are using a calculated Column: 

 

Try with: 

 

Ranking = RANKX(Table1;table1[Net Revenue];;DESC)

 

Regards

 

Victor

Lima - Peru




Lima - Peru

I am getting this error: A single value for column 'Net Revenue' in table 'PH FY 2016' cannot be determined.

 

I used this code...

 

Rank = rankx('PH FY 2016','PH FY 2016'[Net Revenue],,DESC)

The Net Revenue column is not calculated - it was on the Excel table that I imported into Power BI.

I got it working with this code:

 

Rank = rankx(ALLSELECTED('PH FY 2016'[sku]),CALCULATE(SUM('PH FY 2016'[Net Revenue]), ALLEXCEPT('PH FY 2016','PH FY 2016'[sku], 'Cat DICT'[Category])))

@khappersett,

 

Glad to hear that you've solved this problem. You could help mark it as answer. Your contribution is highly appreciated.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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