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
bourne2000
Helper V
Helper V

How to make the if condition for the negative values?

Hi

 

This is follow up to my previous post

 

I have the expiration date column as below

 

bourne2000_0-1643850860747.png

 

I calculated no of days from the expiration column using the below measures

 

No of days = DATEDIFF( 'Expiration Days'[Current Expiration Date],TODAY(), DAY)

 

 

bourne2000_1-1643850904790.png

I want to calculate a new column called status with the following condition,

 

If no of days is within 60 days then I need to create "Expired within 60 days"

 

If no of the day's Will Expire < 1 Week  from Today's date then I need to create “In 1 Week” 

If no of the day's Will Expire < 2 Weeks  from Today's date then I need to create “In 2 Weeks” 

 

 

I used the below dax measure

 

Status = 
IF('Expiration Days'[No of days] > 0 && 'Expiration Days'[No of days] =60, "Expired within 60 days",
IF( 'Expiration Days'[No of days] <= 0 && 'Expiration Days'[No of days] <= -7, "Expire in 1 week", 
IF( 'Expiration Days'[No of days] <= -7 && 'Expiration Days'[No of days] <= -14, "Expire in 2 weeks", "No"))

 

 

Negative values condition is not working, I am getting below

 

bourne2000_2-1643851161735.png

 

 

Can anyone advise? People in the previous posts helped me to rectify it, however, it's not working. 

1 ACCEPTED SOLUTION
SteveHailey
Solution Specialist
Solution Specialist

Hi @bourne2000. I would do it something like this:

Status = 
VAR NumDays = [No of days]
VAR Result =
SWITCH(
    TRUE(),
    NumDays <= -14, "Expire in 2 weeks", 
    NumDays <= -7, "Expire in 1 week",
    NumDays >= 0 && NumDays <= 60, "Expired within 60 days",
    "No"
)
RETURN Result

 

View solution in original post

1 REPLY 1
SteveHailey
Solution Specialist
Solution Specialist

Hi @bourne2000. I would do it something like this:

Status = 
VAR NumDays = [No of days]
VAR Result =
SWITCH(
    TRUE(),
    NumDays <= -14, "Expire in 2 weeks", 
    NumDays <= -7, "Expire in 1 week",
    NumDays >= 0 && NumDays <= 60, "Expired within 60 days",
    "No"
)
RETURN Result

 

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.