Forum Discussion

StanTheMan's avatar
StanTheMan
Frequent Visitor
7 years ago
Solved

Date difference between clients current and previous row

Hi all, I'm looking for a solution to get the date difference between the current row and previous row for every unique client. Below is a very small example of what my dataset looks like for a ...
  • StanTheMan's avatar
    StanTheMan
    7 years ago

    Hi,

    I solved the issue with some more research and luck. The sollution is as followed, after creating the Partition.Index as explained previously, I first create a column that calculates the previous end date.

    previous.enddate =
    Calculate(
    MIN([partition.end]);
    FILTER(Table1; Table1[partition.index] + 1 = Earlier(Table1[partition.index]));
    FILTER(Table1; Table1[id] = EARLIER(Table1[id]))
    )

    This give the previous end date/row from the current id (if unavailable, returns blank). Finally with a simple DATEDIFF calculation I calculate the time between the previous enddate and current startdate and that's pretty much it.

    Daysbetween=
    DATEDIFF(
    Table1[previous.enddate].[Date];
    Table1[partition.start].[Date];
    DAY
    )

    Thanks for replying and giving a nudge in the right direction!