Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Difference between 2 times in the same column

Hi, 

 

I am trying to create a new column that displays the how many minutes have passed between each row in the [Time] Column. Basically, I just need to subtract the bottom row from the above row for all rows. Here's what I have tried, but there is not enough memory to complete the operation. I am wondering if anyone knows a better way around this. 

 

 

7 Replies

  • Anonymous , Try like

    diff =
    var _max = maxx(filter(Table, [date] = earlier([date]) && [time] < earlier([time]) && [material] = earlier([material])),[time])
    return
    [time] - maxx(filter(Table, [date] = earlier([date]) && [time] = _max && [material] = earlier([material])),[time])

  • Anonymous's avatar
    Anonymous
    Not applicable
    Yeah, I know a much better way. Do it in Power Query. Bear in mind that you should never use CALCULATE in a big table when you create a calculated column. This is because CALCULATE performs something that's known as 'context transition' and this operation in very costly. You've just experienced it...
    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous Thanks for the input. How would I go about doing that in the power query editor? 

      • Anonymous's avatar
        Anonymous
        Not applicable
        "Easily" is the answer 🙂 I'll post a solution to this.