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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jack_Reacher
Helper II
Helper II

Creating DAX rules for calculating time difference between received and sent dates of a ticket

I want to create Dax rules to display two dates when the ID_Reciever received the ticket_ID (based on the ID_Receiver column), and simultaneously be able to display the date when the ID_assistant sent the ticket_ID (based on ID_Assistant column), then I want another separate DAX code to calculate time difference between the two dates.

For example, Received ID SD00316 (Kobbe Bryan), received ticket (DOSSIER_Nb) 15729697 on 21/02/2023, then his same "assistant ID" SD00316, sent the ticket 15729697 on 23/02/2023, the time in days it took Kobbe Bryan to treat this ticket is 2 days. How can I translate this into DAX functions please.

This is based on the table below:

DOSSIER_Nb Date_Action Name Assistant ID_Assistant ID_Receiver Name Receiver
15729697 21/02/2023 Jennifer Johnson E580333  SD00316 Kobbe Bryan
15729697 23/02/2023 Kobbe Bryan SD00316 E580333 Jennifer Johnson
15729697 14/03/2023 Jennifer Johnson E580333 SD00316 Kobbe Bryan
15729697 21/03/2023 Kobbe Bryan SD00316 E580333 Jennifer Johnson

I tried the following three DAX codes, but nothing seems to work: 

Received Date = CALCULATE ( MAX ( 'WEEKLY_IDs'[Date_Action] ), FILTER ( 'WEEKLY_IDs', 'WEEKLY_IDs'[DOSSIER_Nb] = 'WEEKLY_IDs'[DOSSIER_Nb] && 'WEEKLY_IDs'[ID_Receiver] = 'WEEKLY_IDs'[ID_Receiver] ) )

Sent Date = CALCULATE ( MAX ( 'WEEKLY_IDs'[Date_Action] ), FILTER ( 'WEEKLY_IDs', 'WEEKLY_IDs'[DOSSIER_Nb] = 'WEEKLY_IDs'[DOSSIER_Nb] && 'WEEKLY_IDs'[ID_Assistant] = 'WEEKLY_IDs'[ID_Assistant] ) )

DaysBetween =

VAR current_ticket_id = MAX(WEEKLY_IDs[DOSSIER_Nb])
VAR current_recipient_id = MAX(WEEKLY_IDs[ID_Receiver])
VAR current_assistant_id = MAX(WEEKLY_IDs[ID_Assistant])
VAR received_date = CALCULATE(                      
MAX(WEEKLY_IDs[Date_Action]),        
             
FILTER(                        
WEEKLY_IDs,                        
WEEKLY_IDs[DOSSIER_Nb] = current_ticket_id &&                        
WEEKLY_IDs[ID_Receiver] = current_recipient_id                       )                     )

VAR sent_date = CALCULATE(                  
MAX(WEEKLY_IDs[Date_Action]),                  
FILTER(                    
WEEKLY_IDs,                    
WEEKLY_IDs[DOSSIER_Nb] = current_ticket_id &&                    
WEEKLY_IDs[ID_Assistant] = current_assistant_id                   )                 )
RETURN DATEDIFF(sent_date, received_date, DAY)




2 ACCEPTED SOLUTIONS
P_d2023
Regular Visitor

Hi, it is tricky as you dont have anything to show when it is a request or a reply

 

i have got through this by first creating 2 custom columns

column 1 ticket timeline. this now ranks the ticket lines in order of date

P_d2023_0-1681127081199.png

secondly i created a new custom column that that ranks the assistant name by date filtered by the ticket

P_d2023_1-1681127166776.png

with the 2 columns we can now create measures to calculate what you are looking for

 

Measure one is ticket_first_recieved_date

this gives us the first time the ticket existed

P_d2023_2-1681127313341.png

second measure is first time someone replied that is different than the first sender

P_d2023_3-1681127405390.png

once we have the 2 dates we can now calculate the days between in a measure

P_d2023_4-1681127451969.png

now we have all the information we can put this into a table as below

P_d2023_5-1681127500616.png

hope this helps

please tick if this is the solution to your issue

regards

 

View solution in original post

Hi Jack you can add an IF stament to the days between calc as below

P_d2023_0-1681138501080.png

this should now show any days that are less than zero as zero

 

regards

 

View solution in original post

3 REPLIES 3
P_d2023
Regular Visitor

Hi, it is tricky as you dont have anything to show when it is a request or a reply

 

i have got through this by first creating 2 custom columns

column 1 ticket timeline. this now ranks the ticket lines in order of date

P_d2023_0-1681127081199.png

secondly i created a new custom column that that ranks the assistant name by date filtered by the ticket

P_d2023_1-1681127166776.png

with the 2 columns we can now create measures to calculate what you are looking for

 

Measure one is ticket_first_recieved_date

this gives us the first time the ticket existed

P_d2023_2-1681127313341.png

second measure is first time someone replied that is different than the first sender

P_d2023_3-1681127405390.png

once we have the 2 dates we can now calculate the days between in a measure

P_d2023_4-1681127451969.png

now we have all the information we can put this into a table as below

P_d2023_5-1681127500616.png

hope this helps

please tick if this is the solution to your issue

regards

 

Kudos to you, BIG Thank you, your answers helped resolve this problem, I just have one question, for the tickets that treated on the same days, it's natural that they don't have a reply date, when I applied the last measure, I get a significant negative number that I just want to show as zero, how can I accomplish this please?

Jack_Reacher_0-1681138023063.png

 

Hi Jack you can add an IF stament to the days between calc as below

P_d2023_0-1681138501080.png

this should now show any days that are less than zero as zero

 

regards

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors