Forum Discussion
Another Rank by Date question
Hello,
Thanks to everyone who has posted 'rank by date' solutions. I'm afraid I've been unable to answer my own query by browsing the contributions of existing posts.
I have a table with multiple projects, which each have multiple authorisation dates (when the budget was expanded). I would like to isolate the second most recent authorisation date for each project. I believe this could be possible if I
1. ranked each project by authorisation date, and then
2. isolate which 'authorisation #' is the second most recent authorisation date. (the authorisation #s do not always go in date order)
My problem in #1 is similar to this post, however, the below code gives me an error message ('A single value for column 'Authorisation Date' cannot be determined').
Rank =
RANKX(
FILTER('Table', 'Table'[Project] = 'Table'[Project]
),
'Table'[Authorisation Date], ,
ASC
)
A sample table is below, with a new column in bold added for what I think I should first do (step #1) and red for the output of step 2.
| Project | Authorisation # | Authorisation Date | Rank |
| A | 1 | 15/01/2020 | 4 |
| A | 2 | 15/03/2020 | 3 |
| A | 3 | 20/09/2020 | 1 |
| A | 4 | 19/06/2020 | 2 |
| B | 1 | 30/01/2020 | 2 |
| B | 2 | 18/04/2020 | 1 |
| C | 1 | 04/09/2020 | 2 |
| C | 2 | 20/05/2020 | 3 |
| C | 3 | 11/10/2020 | 1 |
Thanks in advance for your help!
Anonymous , Are you trying to create a column ?
This should be column with a small change
Rank =
RANKX(
FILTER('Table', 'Table'[Project] = earlier('Table'[Project])
),
'Table'[Authorisation Date], ,
ASC
)Also refer this doc for column Rank
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
2 Replies
- amitchandak
Super User
Anonymous , Are you trying to create a column ?
This should be column with a small change
Rank =
RANKX(
FILTER('Table', 'Table'[Project] = earlier('Table'[Project])
),
'Table'[Authorisation Date], ,
ASC
)Also refer this doc for column Rank
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns - AnonymousNot applicable
Thanks, amitchandak! I see my main issue was that I was trying to create a measure, not a column. When I create a column, your code works. Thank you!