Forum Discussion
Expression.Error: The name 'IF' wasn't recognized. Make sure it's spelled correctly
Hi gcoyle97,
You appear to have used DAX expressions. Keywords in M are written in lower case, hence the error message, M is case sensitive. There are other problems with your code as well, for example there is no standard library function NETWORKDAYS in M, but there are custom function's such as Imke Feldmann's here. ABS = Number.Abs and you have to use explicit type conversion. So this:
IF((NETWORKDAYS([PromisedDeliveryDate],[Ship Date]))<1,(ABS((NETWORKDAYS([PromisedDeliveryDate],[Ship Date])+1)))&" Day(s) Faster then Promised",IF((NETWORKDAYS([PromisedDeliveryDate],[Ship Date]))>1,(NETWORKDAYS([PromisedDeliveryDate],[Ship Date])-1)&" Day(s) Late","On Time"))
Can be translated to the code below. IMPORTANT! First, grab the custom function code from Imke's site, copy it into a new blank query, named: fnNETWORKDAYS Next change your custom column logic to:
if (fnNETWORKDAYS( [PromisedDeliveryDate], [Ship Date] ) <1) then Text.From( Number.Abs( (fnNETWORKDAYS([ PromisedDeliveryDate], [Ship Date] ) +1) ) & " Day(s) Faster then Promised" else if (fnNETWORKDAYS( [PromisedDeliveryDate], [Ship Date] ) <1 ) then Text.From( Number.Abs( (fnNETWORKDAYS([ PromisedDeliveryDate], [Ship Date] ) -1 )) &" Day(s) Late" else "On Time"
I hope this is helpful
Hi, I have followed your instuctions with adding the fuction code into a blank query and using the code.
However, I still have the below error.
I know this is easy to fix I just havent got much experiece yet.
- m_dekorte1 year ago
Resident Rockstar
Hi gcoyle97,
yes I missed a parenthesis, try this:
if (fnNETWORKDAYS([PromisedDeliveryDate], [Ship Date]) < 1) then
Text.From(Number.Abs((fnNETWORKDAYS([PromisedDeliveryDate], [Ship Date]) + 1))) & " Day(s) Faster then Promised"
else if (fnNETWORKDAYS([PromisedDelivryDate], [Ship Date]) < 1) then
Text.From(Number.Abs((fnNETWORKDAYS([PromisedDeliveryDate], [Ship Date]) - 1))) & " Day(s) Late"
else
"On Time"- gcoyle971 year agoFrequent Visitor
Thanks m_dekorte this give me no syntax errors.
But I know have errors in all my cells.
I think this is maybe something to do with the fnNETWORKDAYS query I created?
- m_dekorte1 year ago
Resident Rockstar
Did you open the Advanced Editor and replaced its contents with the code for the Custom Function that was shared? It looks like a string, you may have copied it into the formula bar instead...