Forum Discussion

RalphO's avatar
RalphO
Helper I
7 years ago
Solved

Distance between start and endtime

Hey all,   I have the following data structure:    ID TotalDistance StartTime EndTime 1 1000 10:00   1 1100     1 1300     1 1400   12:00 1 1400 12:20   2 ...
  • Phil_Seamark's avatar
    Phil_Seamark
    7 years ago

    Hi RalphO

     

    Here is how you can do it with a calculated column.  I have attached a PBIX file

     

    Column = 
    VAR StartTotal = 
        MAXX(
            FILTER(
                'Table1',
                Table1[ID] = EARLIER('Table1'[ID]) &&
                'Table1'[TotalDistance] < EARLIER('Table1'[TotalDistance]) &&
                NOT ISBLANK('Table1'[StartTime])
                
                ),[TotalDistance])
    RETURN 
        IF(
            NOT ISBLANK('Table1'[EndTime]),
            'Table1'[TotalDistance] - StartTotal
            )