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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Date Difference with IF Condition

I have the following Table:

 

DAte IF Condition.PNG

 

I want to calculate the service yrs (today-adj_date or today - swd_date) based on the followinf condition:

 

if an employee has an ADJ_DATE, then service yrs should be calculated based on that ( today - adj_date) else if the employee does not have an adj_date then service years should be calculated as today - swd_date.

 

Is there any way to do this? Thank You!

2 ACCEPTED SOLUTIONS
DoubleJ
Solution Supplier
Solution Supplier

You could add a calculated column with this formula

Service Years = 
IF(
    NOT ISBLANK(Employee[ADJ_Date]),
    (TODAY() - Employee[ADJ_Date])/365.25,
    (TODAY() - Employee[SWD_Date])/365.25)

One could argue that the division by 365.25 is not 100% accurate. But this is neglectable in this case I suppose.

emp.png

 

Hope this helps

JJ

View solution in original post

v-lili6-msft
Community Support
Community Support

HI, @Anonymous 

You could use this formula as below:

Column = 
IF(
    ISBLANK('Table'[ADJ_DATE])=FALSE(),
    DATEDIFF('Table'[ADJ_DATE],TODAY(),DAY),
    DATEDIFF('Table'[SWD_DATE],TODAY(),DAY))

Result:

8.JPG

Best Regards,
Lin

Community Support Team _ Lin
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
v-lili6-msft
Community Support
Community Support

HI, @Anonymous 

You could use this formula as below:

Column = 
IF(
    ISBLANK('Table'[ADJ_DATE])=FALSE(),
    DATEDIFF('Table'[ADJ_DATE],TODAY(),DAY),
    DATEDIFF('Table'[SWD_DATE],TODAY(),DAY))

Result:

8.JPG

Best Regards,
Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
DoubleJ
Solution Supplier
Solution Supplier

You could add a calculated column with this formula

Service Years = 
IF(
    NOT ISBLANK(Employee[ADJ_Date]),
    (TODAY() - Employee[ADJ_Date])/365.25,
    (TODAY() - Employee[SWD_Date])/365.25)

One could argue that the division by 365.25 is not 100% accurate. But this is neglectable in this case I suppose.

emp.png

 

Hope this helps

JJ

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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