Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Retrieve Value from Previous Row in Filtered Table

Hi Everyone, I am having trouble accessing the previous row in a filtered table. I'd like to access the previous row so that I can calculate the difference in the date/time between the a value in ...
  • MFelix's avatar
    3 years ago

    Hi Anonymous,

     

    Try the following measure:

     

    Service_Delay = 
    VAR previoustime =
        MAXX (
            TOPN (
                1,
                FILTER (
                    ALLSELECTED (
                        'Routes'[index],
                        'Routes'[start_time],
                        'Routes'[end_time],
                        'Routes'[route]
                    ),
                    'Routes'[index] < SELECTEDVALUE ( 'Routes'[index] )
                ),
                'Routes'[start_time], DESC
            ),
            'Routes'[end_time]
        )
    RETURN
        DATEDIFF ( previoustime, SELECTEDVALUE ( 'Routes'[start_time] ), MINUTE )