Forum Discussion

AC_DATA's avatar
AC_DATA
Frequent Visitor
6 years ago
Solved

Indicate RANK 1 Items Among Groups

I am trying to write some DAX for a calculated column that will return the top-ranked item in its group. In the case of the sample data below, I only want to consider records with the STATUS = "SOLD"...
  • AlB's avatar
    6 years ago

    Hi AC_DATA 

    Try this:

    Col =
    VAR Rank_ =
        RANKX (
            FILTER (
                Table1;
                Table1[ITEM] = EARLIER ( Table1[ITEM] )
                    && Table1[STATUS] = "SOLD"
            );
            Table1[DATE];
            ;
            DESC
        )
    RETURN
        IF ( Rank_ = 1 && Table1[STATUS] = "SOLD"; Rank_ )
    

    Please mark as solved when we get to the solution and consider kudoing if posts are helpful.

    Cheers  Datanaut

     

  • dax's avatar
    6 years ago

    Hi Ac_DATA,

    You also could try below measure

    Measure 8 =
    VAR maxd =
        CALCULATE (
            MAX ( 'rank'[date] ),
            FILTER ( ALLEXCEPT ( 'rank', 'rank'[item] ), 'rank'[status] = "SOLD" )
        )
    RETURN
        IF ( MIN ( 'rank'[date] ) = maxd, 1, "" )
    

    Best Regards,
    Zoe Zhi

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