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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Bananathan
Frequent Visitor

IF Statement does the opposite of what I've typed

So I'm very confused and I've probably missed something obvious but I have these two dates. The one on the left is a selected date in a slicer and the one on the right is the date from a row of data I'm trying to compare: 

Bananathan_0-1662640608622.png

And this measure: (Above date on left is End_of_Month and date on right is [Contractual Leave Date])

VAR End_of_Month = EOMONTH( SELECTEDVALUE('Date Table for Measures'[Date]),0 )
RETURN
IF(
    'HR Turnover Data'[Contractual Leave Date] > End_of_Month,
    "True",
    "False"
    )

 

The statement returns true for the above and switching to a less than sign returns false. Essentially the opposite of what my data would suggest. Any ideas why this is happening?

 

Edit 1: To add, I've noticed the measure DOES work for dates larger than the selected date, it just also returns true for dates below the selected date. Anything blank it returns as FALSE, so something seems to be wrong with the dates. The format of each is the same and I have other measures using the exact same two dates that work perfectly fine.

1 ACCEPTED SOLUTION
Adescrit
Impactful Individual
Impactful Individual

To align the formula with the conditions in your screenshot, you would need to wrap the Contractual Leave Date in a MIN() function. When you add a date column containing mul;tiple date values to a card visual, by default it will return the "Earliest" dates (which is equivalent to the minimum date in the column. 

 

So to align your measure with the conditions in the two cards the DAX would be:

 

VAR End_of_Month = EOMONTH( SELECTEDVALUE('Date Table for Measures'[Date]),0 )
RETURN
IF(
    MIN('HR Turnover Data'[Contractual Leave Date]) > End_of_Month,
    "True",
    "False"
    )

Did I answer your question? Mark my post as a solution!
My LinkedIn

View solution in original post

2 REPLIES 2
Adescrit
Impactful Individual
Impactful Individual

To align the formula with the conditions in your screenshot, you would need to wrap the Contractual Leave Date in a MIN() function. When you add a date column containing mul;tiple date values to a card visual, by default it will return the "Earliest" dates (which is equivalent to the minimum date in the column. 

 

So to align your measure with the conditions in the two cards the DAX would be:

 

VAR End_of_Month = EOMONTH( SELECTEDVALUE('Date Table for Measures'[Date]),0 )
RETURN
IF(
    MIN('HR Turnover Data'[Contractual Leave Date]) > End_of_Month,
    "True",
    "False"
    )

Did I answer your question? Mark my post as a solution!
My LinkedIn
tamerj1
Super User
Super User

@Bananathan 
is [Contractual Leave Date] a measure or a column? In the screenshot it says "Earliest" which has to be considered in the calculation. Please provide more context.

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors