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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Dax calculations to display two dates from one date column, and the time difference between the two.

Hello all, 

I need your help to improve on some Dax functions I have. I have the following sample data related to tickets treated during week number 15 of the month of April 2023, I would like to display the received and sent dates based on the Date of Action column (and only display the dates related to week number 15 of April, I have created a relationship btw between the date table and Date of Action column, but some outputs are still not correct), then calculate the time difference between the two (if the result is zero then it is understood that the ticket treatment was achieved in less than a day). 
Jack_Reacher_0-1681976075264.png

I have implemented the following DAX calculations to get the results I have shown in the Power report below

PERSON_TIMELINE = RANKX(FILTER(WEEKLY_IDsWEEKLY_IDs[Ticket_Nb] = EARLIER(WEEKLY_IDs[Ticket_Nb]) && WEEKLY_IDs[Sender_Name] = EARLIER(WEEKLY_IDs[Sender_Name])), WEEKLY_IDs[Date_of_Action], , ASCDense)

 

TICKET_TIMELINE = RANKX(FILTER(WEEKLY_IDsWEEKLY_IDs[Ticket_Nb] = EARLIER(WEEKLY_IDs[Ticket_Nb])),WEEKLY_IDs[Date_of_Action], , ASCDense)

From the above calculations, I created the three columns shown in the Power BI report below:

RECEIVED_DATE = CALCULATE(MIN(WEEKLY_IDs[Date_of_Action]), ALLEXCEPT(WEEKLY_IDsWEEKLY_IDs[Ticket_Nb]), WEEKLY_IDs[TICKET_TIMELINE]=WEEKLY_IDs[PERSON_TIMELINE]) 

REPLY_DATE =

IF(

    ISBLANK(CALCULATE(MIN(WEEKLY_IDs[Date_of_Action]), ALLEXCEPT(WEEKLY_IDs, WEEKLY_IDs[Ticket_Nb]), WEEKLY_IDs[TICKET_TIMELINE] > WEEKLY_IDs[PERSON_TIMELINE])),

    WEEKLY_IDs[RECEIVED_DATE],

    CALCULATE(MIN(WEEKLY_IDs[Date_of_Action]), ALLEXCEPT(WEEKLY_IDs, WEEKLY_IDs[Ticket_Nb]), WEEKLY_IDs[TICKET_TIMELINE] > WEEKLY_IDs[PERSON_TIMELINE])

)

 
Treatment Duration = if(INT([REPLY_DATE])-INT([RECEIVED_DATE]) <= 0,0,

    INT([REPLY_DATE]) - INT([RECEIVED_DATE]))


 



1 REPLY 1
Wilson_
Super User
Super User

Hello Jack,

 

Can you please share your pbix?

 

I'm also mildly confused on what your actual issue is. Can you be more specific? From what I gather, some Date Received values are not calculating correctly?




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.