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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
CH4R73Y
New Member

Calculating between dates

Ok, so this will be a little long winded. I'm looking to calculate on a couple of different items for offboarding employees in my company, the parameters are below and I'll go through what I'm trying to get afterwards. 

 

Parameters:

Offboarding Ticket Opened/Creation Date

Employee Leave Date

Account Disabled Date

Offboarding Ticket Closed Date

 

Currently I am calculating how long it takes to do the following - in days (all of these are working):

How long from employee leave date to close ticket (Datediff employee leave/ticket close)

How long from employee leave date to disable account (Datediff employee leave/account disabled)

Notification time between ticket opened date and employee leave date ((Datediff ticket opened/employee leave)

 

What I am now trying to do is the following:

If employee leave date is older than ticket opened date*, calculate time to close ticket and to disable account from ticket opened date, if ticket opened date is older than employee leave date, calculate time to close ticket and to disable account from employee leave date.

 

*Essentially some of the offboarding tickets are being raised after the employee has left, so although I still want to know how long it takes to close the account, I want to know this in terms of when we were informed that the employee has left which would come from the ticket opened date, BUT only in the case that the ticket opened date is AFTER the employee leave date. If the ticket opened date is BEFORE the employee leave date then I want to calculate on this. 

 

Hope that makes sense. Let me know if anyone requires more information. 

1 ACCEPTED SOLUTION
CH4R73Y
New Member

Ah, no worries, got it:

 

Days to Close (Offboarding) = IF(HD_TICKET[Employee Leave Date]<HD_TICKET[CREATED], (DATEDIFF(HD_TICKET[CREATED].[Date],HD_TICKET[TIME_CLOSED].[Date],DAY)), (DATEDIFF(HD_TICKET[Employee Leave Date].[Date],HD_TICKET[TIME_CLOSED].[Date],DAY)))
 
and 
 
Account Disabled Days = IF(RELATED(HD_TICKET[Employee Leave Date].[Date])<RELATED(HD_TICKET[CREATED].[Date]), DATEDIFF(RELATED(HD_TICKET[CREATED].[Date]),HD_TICKET_CHANGE[AD Disabled Date].[Date],DAY), DATEDIFF(RELATED(HD_TICKET[Employee Leave Date].[Date]),HD_TICKET_CHANGE[AD Disabled Date].[Date],DAY))

View solution in original post

1 REPLY 1
CH4R73Y
New Member

Ah, no worries, got it:

 

Days to Close (Offboarding) = IF(HD_TICKET[Employee Leave Date]<HD_TICKET[CREATED], (DATEDIFF(HD_TICKET[CREATED].[Date],HD_TICKET[TIME_CLOSED].[Date],DAY)), (DATEDIFF(HD_TICKET[Employee Leave Date].[Date],HD_TICKET[TIME_CLOSED].[Date],DAY)))
 
and 
 
Account Disabled Days = IF(RELATED(HD_TICKET[Employee Leave Date].[Date])<RELATED(HD_TICKET[CREATED].[Date]), DATEDIFF(RELATED(HD_TICKET[CREATED].[Date]),HD_TICKET_CHANGE[AD Disabled Date].[Date],DAY), DATEDIFF(RELATED(HD_TICKET[Employee Leave Date].[Date]),HD_TICKET_CHANGE[AD Disabled Date].[Date],DAY))

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.