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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
hobosapien
Helper I
Helper I

RANKX returning incorrect values for every row

I have put together the following code which returns the first table below
 
EVALUATE
        VAR Table1 = SUMMARIZE('f_Call Metrics','f_Call Metrics'[Agent],"AVG Adherence",AVERAGE('f_Call Metrics'[Adherence %]))
RETURN
    Table1
 
hobosapien_0-1736303287755.png

When I attempt to add a ranking by adding the second line with RANKX it returns a value for each row but they're all much higher than the total number of rows in the table (55 rows total). Where did I go wrong?

 

EVALUATE
        VAR Table1 = SUMMARIZE('f_Call Metrics','f_Call Metrics'[Agent],"AVG Adherence",AVERAGE('f_Call Metrics'[Adherence %]))
        VAR TableRanking = ADDCOLUMNS(Table1,"Rank",RANKX(All('f_Call Metrics'),CALCULATE(AVERAGE('f_Call Metrics'[Adherence %])),,DESC,Dense))
RETURN
    TableRanking

 

hobosapien_1-1736303404334.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @hobosapien ,

 

I suggest you to try code as below.

EVALUATE
        VAR Table1 = SUMMARIZE('f_Call Metrics','f_Call Metrics'[Name],"AVG Adherence",AVERAGE('f_Call Metrics'[Adherence %]))
        VAR TableRanking = ADDCOLUMNS(Table1,"Rank",
		RANKX(Table1,CALCULATE(SUM('f_Call Metrics'[Adherence %]),FILTER(Table1,'f_Call Metrics'[Name] = EARLIER([Name]))),,DESC,Dense))		
RETURN
   TableRanking
ORDER BY [Rank]

Result is as below.

vrzhoumsft_1-1736391193667.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

5 REPLIES 5
ryan_mayu
Super User
Super User

could you pls provide some sample data (not the screenshot) and the expected output?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Sample Data:

 

NameAdherence %
Aubriella Maddox0.317
Aubriella Maddox0.111
Aubriella Maddox0.111
Connor Oliver0.938
Connor Oliver0.978
Connor Oliver0.857
Luke Rosales0.871
Luke Rosales0.847
Luke Rosales0.867

 

Expected Results:

 

AgentAdherenceRank
Connor Oliver0.921
Luke Rosales0.862
Aubriella Maddox0.183
Anonymous
Not applicable

Hi @hobosapien ,

 

I suggest you to try code as below.

EVALUATE
        VAR Table1 = SUMMARIZE('f_Call Metrics','f_Call Metrics'[Name],"AVG Adherence",AVERAGE('f_Call Metrics'[Adherence %]))
        VAR TableRanking = ADDCOLUMNS(Table1,"Rank",
		RANKX(Table1,CALCULATE(SUM('f_Call Metrics'[Adherence %]),FILTER(Table1,'f_Call Metrics'[Name] = EARLIER([Name]))),,DESC,Dense))		
RETURN
   TableRanking
ORDER BY [Rank]

Result is as below.

vrzhoumsft_1-1736391193667.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Your solution works but I found I was not referencing the earlier Summarized table in my RANKX call and that fixed it. Thank you for the help!

@hobosapien 

pls see if this is what you want

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors