Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DAX measure for comparing rows and time difference

Hi, I'm trying to build a measure (called Time Diff) that compares two consecutive rows, in this case the rows in the Time column. As shown in the column on the far right, I want the output to be in...
  • SpartaBI's avatar
    4 years ago

    Anonymous create this measure:

     

    Time Diff = 
    VAR _current_time = SELECTEDVALUE('Table'[Time])
    VAR _previous_time = 
        MAXX(
            FILTER(
                ALL('Table'),
                'Table'[Time] < _current_time
            ),
            'Table'[Time]
        )
    VAR _result = (_current_time - _previous_time) * 86400
    RETURN
        IF(
            NOT ISBLANK(_previous_time), 
            _result
        )

     





          

    Showcase Report – Contoso By SpartaBI