Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Time differences between two date/time values in same column

How can I create a column that will provide the time elapsed between two cells. For example the difference in time between 1:35:21 and 2:20:47 in the second cell of the column labeled column 

 
 

7 Replies

  • az38's avatar
    az38
    Community Champion

    Hi Anonymous 

    this column will return you time difference in seconds

    Column = 
    var _prevDate = calculate(max(Table1[Date/Time]);FILTER(ALL(Table1);Table1[Date/Time]<EARLIER([Date/Time])))
    RETURN
    DATEDIFF(_prevDate;Table1[Date/Time];SECOND)

     

    do not hesitate to give a kudo to useful posts and mark solutions as solution

    • Anonymous's avatar
      Anonymous
      Not applicable

      I am getting the error "There's not enough memory to complete this operation. Please try again later when there may be more memory available."

       

      Any way around this without reducing data size?

      • Anonymous's avatar
        Anonymous
        Not applicable

        Anonymous 'Clear Cache' from File--> Options

  • Icey's avatar
    Icey
    Community Support

    Hi Anonymous ,

     

    Is this problem solved?

     

    Best Regards,

    Icey

    • Anonymous's avatar
      Anonymous
      Not applicable

      The formula works, but I am still getting the error of not enough memory

  • Icey's avatar
    Icey
    Community Support

    Hi Anonymous ,

     

    How about this?

    1. Create a Rank column. Or, you can just add an Index column in Power Query Editor and then use this Index column instead of Rank column in the second expression.

     

    Rank = RANKX('Table','Table'[Date/Time],,ASC,Dense)

     

    2. Create a measure to show the datediff.

     

    Measure = 
    VAR PreDateTime =
        CALCULATE (
            MAX ( 'Table'[Date/Time] ),
            FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Rank] = MAX ( 'Table'[Rank] ) - 1 )
        )
    RETURN
        DATEDIFF ( PreDateTime, MAX ( 'Table'[Date/Time] ), SECOND )

     

    Please close other unnecessary programs.

     

     

    Best Regards,

    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Still running into the issue of power bi endlessly calculating and not creating any results....