Forum Discussion

PJ_01's avatar
PJ_01
Frequent Visitor
1 year ago
Solved

Get the most recent status

I have a table which contains the following data: Date Category Progress_Status 1/14/2024 x 01 1/15/2024 x 02 1/15/2024 x 03 1/17/2024 x 05 1/18/2024 x 04 1/21/2024 ...
  • Deku's avatar
    Deku
    1 year ago

    That is the step one measure, which steps towards the solution. At the end of the blog there are two other version

     

    This was one of them

    // Using TOPN

    VAR currentState = SELECTEDVALUE(States[State])

    VAR currentDate = SELECTEDVALUE('Calendar'[Date])+1

    RETURN

        COUNTROWS(

            FILTER(

                ALL( data[TestID] ),

                SELECTCOLUMNS(

                    TOPN(

                        1,

                        CALCULATETABLE( 

                            FILTER( 

                                'data', 

                                [DateTime] < currentDate

                            )

                            ,REMOVEFILTERS('Calendar'[Date])

                            ,REMOVEFILTERS('States'[State])

                            ),

                        'data'[DateTime], 

                        DESC

                    ),

                    "Last Value", [State]

                    )

                = currentState

                )

            )