Forum Discussion

charlineklapu's avatar
charlineklapu
Frequent Visitor
3 years ago
Solved

Measure to finde time difference between two ordered timestamps within one category

Hi all,   data looks as followed: Customer Opened on Case Status Timestamp   hh:mm:ss     712 18.11.2022 00:00 2100045 In Progress 18.11.2022 07:28         712 18.11....
  • v-xiaosun-msft's avatar
    3 years ago

    Hi charlineklapu .

     

    According to your description, here is my solution, and please follow these steps.

    Firstly, process the data and make sure that your columns "Opened on" and "Timestamp" are Date/time format.

    And then use Power Query to add an index column.

    And then create a calculated column.

     

    Column =
    VAR _a =
        CALCULATE (
            MAX ( 'Table'[Timestamp] ),
            FILTER ( 'Table', [Index] = EARLIER ( 'Table'[Index] ) + 1 )
        )
    VAR _b =
        DATEDIFF ( _a, [Timestamp], HOUR )
    VAR _c =
        CALCULATE (
            MIN ( 'Table'[Timestamp] ),
            FILTER (
                'Table',
                [Customer] = EARLIER ( 'Table'[Customer] )
                    && [Timestamp] > EARLIER ( 'Table'[Timestamp] )
            )
        )
    RETURN
        SWITCH (
            TRUE (),
            [Status] = "Request Processed"
                && ISBLANK ( _c ), "FCR",
            [Status] = "Request Processed"
                && _b > 24, "FCR",
            [Status] = "Request Processed"
                && _b < 24, "n.FCR"
        )

     

    Final output:

     

    I attach my sample below for your reference.

     

    Best Regards,
    Community Support Team _ xiaosun

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