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:

CustomerOpened onCaseStatus
Timestamp
 hh:mm:ss  
71218.11.2022 00:002100045In Progress18.11.2022 07:28    
71218.11.2022 00:002100045Closed18.11.2022 07:33    
71218.11.2022 00:002100146In Queue18.11.2022 07:40    
71219.11.2022 00:002103706New19.11.2022 07:37    
71219.11.2022 00:002103706New19.11.2022 07:37    
71219.11.2022 00:002103706Request Processed19.11.2022 07:37 00:04:00<24hn.FCR
71218.11.2022 00:002100146In Queue19.11.2022 07:41    
71218.11.2022 00:002100146In Queue21.11.2022 07:44    
71218.11.2022 00:002100146In Queue21.11.2022 07:53    
71218.11.2022 00:002100146In Progress21.11.2022 07:53    
71218.11.2022 00:002100146Request Processed21.11.2022 07:57  >24hFCR
         
12418.11.2022 00:002100546New21.11.2022 17:00    
12418.11.2022 00:002100546Request Processed21.11.2022 17:57  >24hFCR
         
23418.11.2022 00:002100946New21.11.2022 17:00    
23418.11.2022 00:002100946Request Processed21.11.2022 17:57 01:00:00<24hn.FCR
23418.11.2022 00:002100946in Queue21.11.2022 18:57    
23418.11.2022 00:002100946Request Processed24.11.2022 19:57  >24hFCR

 

I want to look at customers and his/her cases (One customer can have one-many cases). Once a case reached the status "request processed" at time stamp column it can either be "FCR" or "n.FCR" (FCR standing for first call resolution). A case can reach "request processed" multiple times. 

FCR would mean that after the status "request processed" was reached, there were no further changes (no matter which status) to the case within 24 hours. 

Therefore at each status "request processed" I want to have a column indicating wether it is "FCR" or "n.FCR". Shown by example column on top in orange color.

 

Thank you for your help!

  • 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.

2 Replies

  • v-xiaosun-msft's avatar
    v-xiaosun-msft
    Community Support

    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.

  • charlineklapu's avatar
    charlineklapu
    Frequent Visitor

    Hi,

     

    thanks for your answer. 

     

    How do I set up an Index column while using direct query in an sql analysis server datasource? While using this mode and going into power query editor I see no queries.

     

    Thanks for the help again!