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
NickProp28
Post Partisan
Post Partisan

Date difference and return TRUE/FALSE

Dear Community, 

 

DATE ADATE B
27/6/202029/6/2020
1/7/202029/6/2020

 

I looking for a formula that can substract (DATEA - DATEB) and return false/true if its more than 7 days.

I tried DATEDIFF, but its return some weird date value and there might DATEB will have lower date than DATEA. 

Greatly appreciate for the helps.

 

Best thanks.

 

3 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@NickProp28 

if(abs(datediff([Date A],[Date B],Day)) <=7, "Yes","NO")

View solution in original post

V-pazhen-msft
Community Support
Community Support

@NickProp28 

What is your formula? Should be like:

 

Column = IF(DATEDIFF([Date A],[Date B],DAY)>7,TRUE(),FALSE())

 

Paul Zheng _ Community Support Team
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

@NickProp28 , Something like this. Change as per need

if((abs(datediff([Date A],[Date B],Day)) <=7) || (isblank([Date A]) ||isblank([Date B]) ), "Yes","NO")

View solution in original post

6 REPLIES 6
V-pazhen-msft
Community Support
Community Support

@NickProp28 

What is your formula? Should be like:

 

Column = IF(DATEDIFF([Date A],[Date B],DAY)>7,TRUE(),FALSE())

 

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

 

Dear @V-pazhen-msft @amitchandak ,

Appreciate for the solution. It works perfectly for me.
May I ask, what should be the formula if either one of the Date (DateA/DateB) is blank. I want it return True instead of False. 

 

Best thanks.

@NickProp28 , Something like this. Change as per need

if((abs(datediff([Date A],[Date B],Day)) <=7) || (isblank([Date A]) ||isblank([Date B]) ), "Yes","NO")

Dear @amitchandak ,

 

Many thanks for the prompt reply. 

 

amitchandak
Super User
Super User

@NickProp28 

if(abs(datediff([Date A],[Date B],Day)) <=7, "Yes","NO")

Hello,

 

please can you tell me if this can be adapted for Work Days (Mon-Fri) only?

 

many thanks 

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.