Forum Discussion
adoster
4 years agoResolver I
Dax Help: Performing a Count by Ranking system
Hello,
I am trying to do a count of procedures based on a ranking system. So that it only counts the 1st rank and not subsequent ranks on any given day.
If a Person has multiple procedures on the same day, it should only return a count of the lowest rank (between 1-3)
Example and desired results:
| Date | Name | Procedure Name | Rank |
| 11/8/2021 | Donald Duck | Procedure A | 1 |
| 11/8/2021 | Donald Duck | Procedure B | 2 |
| 11/8/2021 | Mickey Mouse | Procedure A | 1 |
| 11/8/2021 | Mickey Mouse | Procedure B | 2 |
| 11/9/2021 | Donald Duck | Procedure A | 1 |
| 11/9/2021 | Donald Duck | Procedure C | 3 |
| 11/9/2021 | Mickey Mouse | Procedure B | 1 |
| 11/10/2021 | Mickey Mouse | Procedure C | 3 |
| Desired Results | |||
| Date | Procedure Display Name | Count by Rank | |
| 11/8/2021 | Procedure A | 2 | |
| 11/8/2021 | Procedure B | 0 | |
| 11/8/2021 | Procedure C | 0 | |
| 11/9/2021 | Procedure A | 1 | |
| 11/9/2021 | Procedure B | 1 | |
| 11/9/2021 | Procedure C | 0 | |
| 11/10/2021 | Procedure A | 0 | |
| 11/10/2021 | Procedure B | 0 | |
| 11/10/2021 | Procedure C | 1 | |
| Total Count | 5 |
I need to be able to graph the individual procedure counts based off this logic. Not just the total.
2 Replies
- amitchandakSuper User
adoster , Create a column
Rank = rankx(filter(Table, [Date] =earlier([Date]) && [Name] = earlier([Name]) ), [Procedure Name],,asc, dense)and then a measure
Count Rank = calculate(count(Table[Rank]), allexcept(Table, Table[Name], Table[Date]), filter(Table Table[Rank]=1))
- adosterResolver ITried your suggestion.DAX didn't recognize the ",,asc, dense" portion. I tried just leaving it out.Here is what I tried using my table/column names.Rank = RANKX(FILTER('All Data','All Data'[SERVICE DATE] = earlier('All Data'[SERVICE DATE] && 'All Data'[PATIENT NAME], [PROCEDURE_DESC])))I'm unsure what values we are trying to generate on this column.This returns an #ERROR down the column.I should note that my Rankings column is on a separate Excel file that I've imported in linked by the [PROCEDURE_DESC]