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

RANKX Always Returns 1

I am trying to learn the RANKX expression using a couple examples on the web but every row returns 1.  I have found a couple suggested solutions, none of which have worked for me.

 

I have simplified my data set to just 3 rows in a <name, value> table as follows:

 

Name   Value

A          3

B          1

C          2

 

I create a new measure as:

Total = SUM(MyData[Value]) 

Then create a new column as:

MyRank = RANKX(ALL(MyData[Name]), [Total]) 

I have tried ALL(MyData) and ALL(MyData[Value]) as the first argument with no luck.  I have also tried computing the sum within the second argument both with and without CALCULATE, again no luck.

MyRank = RANKX(ALL(MyData[Value]), CALCULATE(SUM(MyData[Value])))

I don't know how I can possibly make this example simpler and I've exhausted all my research on this.  Please help.

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

@amilecki

If you do want to use a Rank Measure in the Visual Filter you have to adjust how the sum is calculated like this...

Rank Product = 
RANKX ( ALL(MyData[Product] ), CALCULATE ( SUM ( MyData[Quantity] ), ALLEXCEPT(MyData, MyData[Product] ) ) )

See below...

TOPN - Built-In 2 with RANKX.gif

Hope this helps! Smiley Happy

View solution in original post

14 REPLIES 14

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.