Forum Discussion

tvalente's avatar
tvalente
Helper I
4 years ago
Solved

How to do rank partition like SQL in DAX

Hi All,   I am trying to return a column where in SQL you would rank by partition and sort the date descending. I am successfully ranking the max insurance date but am struggling to return the insu...
  • tvalente's avatar
    tvalente
    4 years ago

    Found a solution from the sqlbi guys:

     

    As below this works as a calculated column:

     

    VaccineRank =
    VAR CurrentEmployee = 'Employee List'[Employee number]
    VAR EmployeesGroup =
    FILTER (
    'Employee List',
    'Employee List'[Employee number] = CurrentEmployee
    )
    RETURN
    RANKX (
    EmployeesGroup,
    'Employee List'[Vaccine Date],,DESC
    )