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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors