Forum Discussion

kiddknee's avatar
kiddknee
New Member
5 years ago
Solved

Sorting single value column 'descending' by latest week ending date

  Problem: Table needs to be sorted 'descending' for column "3/30/21".  Value is a Dax Measure and latest date changes each week. Can't seem to find how to do this in visual or through PQ   ...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi kiddknee ,

     

    Please try the following formula:

    Rank =
    IF (
        MAX ( 'Table'[Date] ) = MAXX ( ALL ( 'Table' ), [Date] ),
        RANKX (
            FILTER ( ALL ( 'Table' ), 'Table'[Date] = MAX ( 'Table'[Date] ) ),
            CALCULATE ( [Your Measure] ),
            ,
            ASC,
            DENSE
        ),
        0
    )
    
    Sort =
    IF (
        HASONEVALUE ( 'Table'[Date] ) = FALSE (),
        MAXX (
            FILTER ( 'Table', 'Table'[Agent Name] = MAX ( 'Table'[Agent Name] ) ),
            [Rank]
        )
    )
    

    The final output is shown below:

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