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
Arroios2020
Regular Visitor

Calculate Response Time each time

Hi
I am having trouble to calculate the response time of each message.

I have ID_Conversation for each conversation and a conversation can have multiple messagas (Content column). The column is_by_source tell me if the message was published by me or the client. What I want to know is how many hours and minutes I took to answer each message of client (is_by_source=False) and also how many time it took the customer to answer. Here it is the table:

 ABCDEF
1Id_ConversationsCreated_DateTimeContent_TypeIs_By_SourceContentDesired
25ee9cee62e583f6432901f7317/06/2020 08:05messageFALSEtext 
35ee9cee62e583f6432901f7317/06/2020 09:08messageTRUEtext101:02:04 (B3-B2)
45eeacde9458a68a0d944eaf918/06/2020 02:13postFALSEtext2 
55eeacde9458a68a0d944eaf918/06/2020 08:34commentTRUEtext306:20:23 (B5-B4
65eeacde9458a68a0d944eaf918/06/2020 09:22messageFALSEtext400:47:41 (B6-B5)
75eeacde9458a68a0d944eaf918/06/2020 09:47messageTRUEtext500:25:42 (B7-B6)

Can you help me?

Thanks!



1 ACCEPTED SOLUTION

Hi @Arroios2020 

Column =
RANKX (
    FILTER (
        'Table',
        'Table'[Id_Conversations] = EARLIER ( 'Table'[Id_Conversations] )
    ),
    [Created_DateTime],
    ,
    ASC,
    DENSE
)


Column 2 =
CALCULATE (
    MAX ( 'Table'[Created_DateTime] ),
    FILTER (
        'Table',
        'Table'[Id_Conversations] = EARLIER ( 'Table'[Id_Conversations] )
            && 'Table'[Column]
                = EARLIER ( 'Table'[Column] ) - 1
    )
)


Column 3 =
VAR ts =
    IF (
        [Column 2] <> BLANK (),
        DATEDIFF ( [Column 2], [Created_DateTime], SECOND )
    )
VAR h =
    INT ( ts / 3600 )
VAR d =
    INT ( h / 24 )
VAR m =
    INT ( MOD ( ts, 3600 ) / 60 )
VAR s = ts - h * 3600 - m * 60
VAR hh =
    IF ( LEN ( h ) = 1, 0 & h, h )
VAR mm =
    IF ( LEN ( m ) = 1, 0 & m, m )
VAR ss =
    IF ( LEN ( s ) = 1, 0 & s, s )
RETURN
    IF (
        [Column 2] <> BLANK (),
        IF (
            d = BLANK (),
            hh & ":" & mm & ":" & ss,
            d & " " & hh & ":" & mm & ":" & ss
        )
    )

Capture13.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
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

5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @Arroios2020 

Great blog from Greg_Deckler, hope that provides ideas to slove your problem.

If not, please feel free to ask here.

 

Best Regards

Maggie

Greg_Deckler
Community Champion
Community Champion

@Arroios2020 - See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 

 

Great article! I tried to use your formula but still I am having osme problems:


Last_Reply =

VAR next = MINX(FILTER(Table1,

Table1[Id_Conversations]=EARLIER(Table1[Id_Conversations]) &&

Table1[Created_DateTime]>EARLIER(Table1[Created_DateTime]) &&

Table1[Is_By_Source]<>"True"

),Table1[Created_DateTime])

RETURN IF(Table1[Is_By_Source]="False", 0,IF(ISBLANK(next),

DATEDIFF(Table1[Created_Date],NOW(),HOUR),

DATEDIFF(Table1[Created_Date],next,HOUR)

)

)

The results does not look ideal:

 

Id_ConversationsId_ContentCreated_DateTimeLast_ReplyContent_TypeIs_By_SourceContent
5eeacde9458a68a0d944eaf95eeacde80314c8640ea3ae3e18/06/2020 02:130postFALSExxx
5eeacde9458a68a0d944eaf95eeb270e1326c983451a0b2918/06/2020 08:3418commentTRUExxxxx
5eeacde9458a68a0d944eaf95eeb32398c610c9a94ed752a18/06/2020 09:220messageFALSExxxxxxx
5eeacde9458a68a0d944eaf95eeb383e07f3f3d26e26871218/06/2020 09:471024messageTRUExxxx

Hi @Arroios2020 

Column =
RANKX (
    FILTER (
        'Table',
        'Table'[Id_Conversations] = EARLIER ( 'Table'[Id_Conversations] )
    ),
    [Created_DateTime],
    ,
    ASC,
    DENSE
)


Column 2 =
CALCULATE (
    MAX ( 'Table'[Created_DateTime] ),
    FILTER (
        'Table',
        'Table'[Id_Conversations] = EARLIER ( 'Table'[Id_Conversations] )
            && 'Table'[Column]
                = EARLIER ( 'Table'[Column] ) - 1
    )
)


Column 3 =
VAR ts =
    IF (
        [Column 2] <> BLANK (),
        DATEDIFF ( [Column 2], [Created_DateTime], SECOND )
    )
VAR h =
    INT ( ts / 3600 )
VAR d =
    INT ( h / 24 )
VAR m =
    INT ( MOD ( ts, 3600 ) / 60 )
VAR s = ts - h * 3600 - m * 60
VAR hh =
    IF ( LEN ( h ) = 1, 0 & h, h )
VAR mm =
    IF ( LEN ( m ) = 1, 0 & m, m )
VAR ss =
    IF ( LEN ( s ) = 1, 0 & s, s )
RETURN
    IF (
        [Column 2] <> BLANK (),
        IF (
            d = BLANK (),
            hh & ":" & mm & ":" & ss,
            d & " " & hh & ":" & mm & ":" & ss
        )
    )

Capture13.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This worked great! But, I need help now converting that column from text to time. Thanks!

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