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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
LABrowne
Helper II
Helper II

DAX: How use dates in an IF function

Hi there,

 

Am currently working on an if function and have completed most of it, please see below:

 

VAR = IF( [QualityCheck(%)] > 1 && Order[NumberProductsOrdered] >= 2, "Green", BLANK())
 
Orders have an expiry date a year after delivery. I need another condition within the logical test bit which is that DONT consider orders within 3 months of it's expiry date. Expiry date is it's own column.
 
Any help greatly appreciated.
 
Kind regards,
Luke
1 ACCEPTED SOLUTION
WinterMist
Impactful Individual
Impactful Individual

@LABrowne 

 

Please try something like the following:

 

VAR = 
IF( 
[QualityCheck(%)] > 1 
&& Order[NumberProductsOrdered] >= 2
&& TODAY() < 'Table'[Expiry Date] - 90, --TODAY IS BEFORE 90 DAYS LEADING UP TO THE EXPIRY DATE
"Green", 
BLANK()
)
 
NOTE: In this example, I used TODAY().  However, if you need to compare it to a different date (i.e. Order[Order Date]), then simply switch to the desired date.
 
Regards,
Nathan

View solution in original post

2 REPLIES 2
WinterMist
Impactful Individual
Impactful Individual

@LABrowne 

 

Please try something like the following:

 

VAR = 
IF( 
[QualityCheck(%)] > 1 
&& Order[NumberProductsOrdered] >= 2
&& TODAY() < 'Table'[Expiry Date] - 90, --TODAY IS BEFORE 90 DAYS LEADING UP TO THE EXPIRY DATE
"Green", 
BLANK()
)
 
NOTE: In this example, I used TODAY().  However, if you need to compare it to a different date (i.e. Order[Order Date]), then simply switch to the desired date.
 
Regards,
Nathan
FreemanZ
Super User
Super User

hi @LABrowne ,

 

What do you mean by "DONT consider orders within 3 months of it's expiry date", or what should be return in this case?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.