Forum Discussion

MarkCBB's avatar
MarkCBB
Icon for Helper V rankHelper V
8 years ago
Solved

2nd last date per item

Hi there,   I need to create a measure that filters another measure to the 2nd last date. for example, For BP Charles I would like the measure to return the 41.2% score as it is the 2nd last score...
  • Zubair_Muhammad's avatar
    8 years ago

    Hi Mark MarkCBB

     

    Please try this MEASURE

     

    Measure =
    VAR SecondLastDate =
        MINX (
            TOPN (
                2,
                CALCULATETABLE (
                    VALUES ( TableName[DATE] ),
                    ALLEXCEPT ( TableName, TableName[STORE] )
                ),
                TableName[DATE], DESC
            ),
            TableName[DATE]
        )
    RETURN
        CALCULATE (
            [TotalAverageScore],
            FILTER (
                ALLEXCEPT ( TableName, TableName[STORE] ),
                TableName[DATE] = SecondLastDate
            )
        )