RANKX with COUNT/SUM function

_eNVy_

Board Regular
Joined
Feb 9, 2018
Messages
66
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Stuck with the following :

NameDue StatusActive Overdue
Person 1On Time0
Person 1Overdue1
Person 1Overdue1
Person 2Overdue1
Person 2Overdue1
Person 2Overdue1
Person 3Overdue1
Person 3Overdue0
Person 3On Time0

The above is the table from which I am building my report from.
In my report I would like to show the following :

NameRank
Person 21
Person 12
Person 32

I have tried various different types of RANK CALCULATE formulas but cannot seem to get it to produce the numbers I want!

Tried RANKX with COUNT and RANKX with SUM. I am missing something.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Use this method
Book1
ABCDEFGH
1NameDue StatusActive OverdueRankNameCountifs
2Person 1On Time01Person 23
3Person 1Overdue12Person 12
4Person 1Overdue13Person 32
5Person 2Overdue1
6Person 2Overdue1
7Person 2Overdue1
8Person 3Overdue1
9Person 3Overdue0
10Person 3On Time0
11
12
Sheet1
Cell Formulas
RangeFormula
G2:G4G2=COUNTIFS($A$2:$A$10,$F$2:$F$4,$B$2:$B$10,"Overdue")
 
Upvote 0
Hi,

Before I start working with DAX, can you please explain how your ranking works? I.e. Why Person 1 and 3 have the same ranking (2)? Is it based on the count of "On Time" occurrences?
 
Upvote 0
Hi,

Before I start working with DAX, can you please explain how your ranking works? I.e. Why Person 1 and 3 have the same ranking (2)? Is it based on the count of "On Time" occurrences?

NameDue StatusActive Overdue
Person 1On Time0
Person 1Overdue1
Person 1Overdue1
Person 2Overdue1
Person 2Overdue1
Person 2Overdue1
Person 3Overdue1
Person 3Overdue1
Person 3On Time0

So sorry! The Active Overdue looks for the word "Overdue" and issues a 1 if there is and 0 if anything else.
 
Upvote 0
No worries at all & thanks for clarifying :)

One solution might be to create a dynamic DAX table using the following formula:

1613478755226.png


Rich (BB code):
tRank = 
    var temp = 
        SUMMARIZE(
            FILTER(tblOverdue, tblOverdue[Due Status] = "Overdue"), tblOverdue[Name], 
            "Sum Overdue", SUM(tblOverdue[Active Overdue]))
return
    ADDCOLUMNS(temp, "Rank", RANKX(temp, [Sum Overdue]))

1613478777322.png


You can then use this table on your visualization, e.g.:

1613478812476.png


Does that work for you? Or do you need to have a solution that is not a DAX table, i.e. DAX column / measure / Power Query?
 
Upvote 0
Solution
For a measure, I think you'd just need one measure that sums the ActiveOverdue field (let's call it NumOverdue) then add a new measure using that - something like:

RANKX(ALL(Table1[Name]),[NumOverdue])
 
Upvote 0
No worries at all & thanks for clarifying :)

One solution might be to create a dynamic DAX table using the following formula:

View attachment 32232

Rich (BB code):
tRank =
    var temp =
        SUMMARIZE(
            FILTER(tblOverdue, tblOverdue[Due Status] = "Overdue"), tblOverdue[Name],
            "Sum Overdue", SUM(tblOverdue[Active Overdue]))
return
    ADDCOLUMNS(temp, "Rank", RANKX(temp, [Sum Overdue]))

View attachment 32233

You can then use this table on your visualization, e.g.:

View attachment 32234

Does that work for you? Or do you need to have a solution that is not a DAX table, i.e. DAX column / measure / Power Query?
Thank you for your swift reply!

I used your DAX formula and I had to change it slightly (I have a filter on the page which for some reason was not applying to the table) but it works!

Thank you very much!
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top