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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Remco1986
Helper I
Helper I

Why is this RANKX not working?

I have data as per below:

Attribute CategorySectionAttributePointsMax Points
AttributeSection 1Question 11790.001820.00
AttributeSection 2Question 21315.001455.00
AttributeSection 2Question 32610.002950.00
AttributeSection 3Question 42015.002080.00
AttributeSection 3Question 52925.002950.00
AttributeSection 4Question 62845.002930.00
AttributeSection 4Question 74395.004910.00
AttributeSection 4Question 8785.00810.00
AttributeSection 4Question 91890.001980.00
AttributeSection 4Question 101104.001122.00
AttributeSection 4Question 111882.501945.00
AttributeSection 5Question 12507.50545.00
AttributeSection 5Question 132267.502405.00
AttributeSection 5Question 142640.002745.00
AttributeSection 5Question 152547.502950.00
AttributeSection 5Question 165000.005820.00
AttributeSection 5Question 171295.001410.00
AttributeSection 6Question 189840.0011800.00
AttributeSection 6Question 19960.001095.00
AttributeSection 6Question 20400.00480.00
AttributeSection 6Question 21132.50155.00
AttributeSection 7Question 22352.50425.00
AttributeSection 7Question 231685.001980.00
AttributeSection 8Question 241975.002420.00
MasterTotal ResultTotal Result  
SectionSection 1 1790.001820.00
SectionSection 2 3802.504405.00
SectionSection 3 4885.005030.00
SectionSection 4 12901.5013697.00
SectionSection 5 13912.5015875.00
SectionSection 6 11267.5013530.00
SectionSection 7 2037.502405.00
SectionSection 8 1975.002420.00

 

and a measure to calculate pass rate:

(%) Pass Rate = iferror(sum('QA Data'[Points])/sum('QA Data'[Max Points]),BLANK())

 

 

 

Now, I can display a simple table visual with the Pass Rate per Attribute (with a visual filter on Attribute Category = Attribute) and a table visual with the Pass Rate per Section (with a visual filter on Attribute Category = Section).

 

Now, I need to color-code the top 5 and bottom 5 attributes. After searching the web, the best approach seems to be to create a rank measure, and then look at rank 1 through 5 for the top 5, and rank 19 through 24 for the bottom 5 (cause there are 24 arrtibutes).

 

However, every different RANKX approch I have used so far results in either rank 1 for all attributes, or rank with very high numbers (matches rows of data, example the highest pass rate has rank 1, then the next attribute has rank 388 meaning there are 387 rows for the same attribute that got rank 1).

 

All I need is a rank 1 through 24. What am I doing wrong?

1 ACCEPTED SOLUTION
Remco1986
Helper I
Helper I

After some troubleshooting, I have found the solution. Let me explain:

I have a 2nd table with the sortOrder of the questions. In my main data, I have added the sortorder using the RELATED() function. I then sorted the Attribute text by the sortOrder.

 

This is what broke the RANKX. All I needed to do was to include the sortOrder in the RANKX function.

 

So this: 

 

RANKX(all('QA Data'[Attribute]),calculate(sum('QA Data'[Points])/sum('QA Data'[Max Points])),,DESC,dense)

 

 

Should be changed to this:

 

RANKX(all('QA Data'[Attribute],'QA Data'[sortAttribute]),calculate(sum('QA Data'[Points])/sum('QA Data'[Max Points])),,DESC,dense)

 

Or shorter, I could use the Pass Rate measure instead of the CALCULATE(SUM()/SUM())

 

RANKX(all('QA Data'[Attribute],'QA Data'[sortAttribute]),[(%) Pass Rate],,DESC,dense)

 

 

View solution in original post

1 REPLY 1
Remco1986
Helper I
Helper I

After some troubleshooting, I have found the solution. Let me explain:

I have a 2nd table with the sortOrder of the questions. In my main data, I have added the sortorder using the RELATED() function. I then sorted the Attribute text by the sortOrder.

 

This is what broke the RANKX. All I needed to do was to include the sortOrder in the RANKX function.

 

So this: 

 

RANKX(all('QA Data'[Attribute]),calculate(sum('QA Data'[Points])/sum('QA Data'[Max Points])),,DESC,dense)

 

 

Should be changed to this:

 

RANKX(all('QA Data'[Attribute],'QA Data'[sortAttribute]),calculate(sum('QA Data'[Points])/sum('QA Data'[Max Points])),,DESC,dense)

 

Or shorter, I could use the Pass Rate measure instead of the CALCULATE(SUM()/SUM())

 

RANKX(all('QA Data'[Attribute],'QA Data'[sortAttribute]),[(%) Pass Rate],,DESC,dense)

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.