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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Formula error: Expression.Error. The name 'IF' wasn't recognized. Make sure it's spelled correctly.

I'm using Power Query Editor to create a new column using an if statement. I used the conditional column to create the formula but now I get the below error.  How can I fix this If then statement? See screen shot below.

 

The formula is supposed to look at the column [Loading Date] and if this column is less than today's date than put today's date or else keep the original [Loading Date] value

 

if error.png

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

@Anonymous ,

 

Modify the formula as below:

= Table.AddColumn(#"Renamed Columns2", "Custom", each if 
[Loading Date] > DateTime.LocalNow() then [Loading Date] else DateTime.LocalNow())

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thanks...I tried changing it to the below but now the rows all show as Error. When I click on the error I get an Expression Error. See below screen shot.

 

Any ideas how to fix?

 

error2.png

@Anonymous ,

 

Modify the formula as below:

= Table.AddColumn(#"Renamed Columns2", "Custom", each if 
[Loading Date] > DateTime.LocalNow() then [Loading Date] else DateTime.LocalNow())

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Syntax and function is different for M...an example is shown below

 

if [FullDateAlternateKey] = Date.From(DateTime.LocalNow()) then [FullDateAlternateKey] else Date.From(DateTime.LocalNow()))

Greg_Deckler
Community Champion
Community Champion

TODAY is a DAX function and therefore invalid M code. You need to use DateTime.LocalNow. Also, drop your parens. M code if statement is:

 

if <condition> then <true> else <false>

 

<condition>, <true> and <false> are placeholders.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors