Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
charlineklapu
Frequent Visitor

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!

1 ACCEPTED SOLUTION
v-xiaosun-msft
Community Support
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.

vxiaosunmsft_0-1669604396483.png

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:

vxiaosunmsft_2-1669605503833.png

 

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.

View solution in original post

2 REPLIES 2
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!

 

 

v-xiaosun-msft
Community Support
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.

vxiaosunmsft_0-1669604396483.png

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:

vxiaosunmsft_2-1669605503833.png

 

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.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.