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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

M Query Returns Error for Calculated column referencing null values of date column

arikofather_0-1678812853810.png

 

I have a calculalted M query column 

Receive and Close Date Flag

if
([Actual Closed Date] >= #"Parameter Date Closed Start Date"
or
[Date Received] >= #"Parameter Date Received Start Date" and [Deal Status Display] = "Open")
then "True" else "False"

 

And two Parameter of same date value is set at

 

arikofather_4-1678813092840.png

 

Note that the result column is showing Error whe the Actual Close Date is Null  

 

How can I fix this in my dax ?

8 REPLIES 8
AndrewPF
Helper V
Helper V

Please mark the solution as "Accepted" if this works for you.  Thanks. 

AndrewPF
Helper V
Helper V

If I type in the code exactly as described in my previous post, including the "try" at the beginning, and without the erroneous brackets, it works: 

AndrewPF_0-1679066329492.png

 

AndrewPF
Helper V
Helper V

This is the code:

try if [Actual Date Closed] >= #"Parameter Date Closed Start Date" or [Date Received] >= #"Parameter Date Received Start Date" and [Deal Status Display] = "Open" then "True" else "False" otherwise null

It was Actual Date Closed, not Actual Closed Date, and there were some erroneous brackets

Anonymous
Not applicable

It is not working for me.  Can you please update or test it out in the PBIX.   

As an FYI,  the cells showing as Error should display as False or True. 

 

arikofather_0-1679064897393.png

 

 

AndrewPF
Helper V
Helper V

You need a "try" in front of the "if". 

The syntax is: 

try [THIS] otherwise [THAT]

where [THIS] is what you want to calculate i.e. your entire "IF" statement, and [THAT] is what you want to display if your calculation fails for any reason. 

Anonymous
Not applicable

This gives Token eof Expected error.

 

 

arikofather_0-1678815789005.png

 

AndrewPF
Helper V
Helper V

Use this:

try if([Actual Closed Date] >= #"Parameter Date Closed Start Date" or [Date Received] >= #"Parameter Date Received Start Date" and [Deal Status Display] = "Open") then "True" else "False" otherwise null

see also: 

Error handling - Power Query | Microsoft Learn

Anonymous
Not applicable

 

arikofather_0-1679024223616.png

 

 

I have a PBIX attached and Excel Data File.  

Date Flag Table.pbix

Date Flag Table.xlsx

 

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.