Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi im trying the most simple query. Any help?
if ([Actual End Date] < [Target End Date])
then 1
else 0
If date1 is less then date2 then put 1 in the column otherwise put 0.
Error: Expression.Error: We cannot convert the value null to type Logical.
Support?
Solved! Go to Solution.
if ([Actual End Date] ?? #date(1,1,1)) < ([Target End Date] ?? #date(1,1,1)) then 1 else 0
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
if ([Actual End Date] ?? #date(1,1,1)) < ([Target End Date] ?? #date(1,1,1)) then 1 else 0
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hi thanks for answering. I need to do the same thing but replace [Actual End Date] with Today() or something which works simular:
if (DateTime.Now() < ([Target End Date] ?? #date(1,1,1)) then 1 else 0
Something simular to above should work. Any support?
if (DateTime.LocalNow() <...
--Nate
Ahh never thought to use the ?? In an if comparison--very cool.
--Nate
You have a null in one of your date fields, so null > date isn't valid. Try each if is null [Actual End Date] or [Actual End Date] < [Target End Date] then 1 else 0
--Nate
I have tried on this dummy data and it is working as per your requirement.
I added one custom column with the formula mentioned below:
Try this and if my solution solves your doubt then please consider it as a solution.
Hi @Anonymous
We need more info, I did a test on a simple dataset and it works...send us more code
It is very difficult for someone to help you in this case. if only this formula is not wrong. but it is used with many other formulas to know where is wrong.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
13 | |
8 | |
8 | |
7 |
User | Count |
---|---|
17 | |
11 | |
7 | |
6 | |
6 |