Expression error: The name 'IF' wasn't recognized​. Make sure it's spelled correctly. Power BI/DAX Functions/Power Query

I had this question after viewing Power Query Switch Function vs If statement.

After numerous hours of researching this issue for 2 days, I am really stumped.

I have tried to create a simple function of either If or Switch and both return the above mentioned error.

I even created a sample based on the example supplied on MSDN for the IF Function, trying to use it both in the Power BI Desktop and/or Power Query for Excel 2013 (32 bit) environments. Without any luck.

I am using the latest download of Power query and PBI,  I just set up my computer in the last week.  Urgently need of help.


Karen SchaeferBI ANALYSTAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongSoftware Team LeadCommented:
what error are you encountered?

>>Keywords are case-sensitive; "if", "then" and "else" must all be lower-case

would this help?
Karen SchaeferBI ANALYSTAuthor Commented:
thanks for the suggestion,  I need to add another layer to this statement to check for Date in a different column(Termed).

if([#"#YearsofService"]>=2) then "2 + Years" else "Less Than 2 Years"

What do I have to include, maybe hasonevalue or Blank()?

if(hasonevalue([Term Date]),"Termed" if([#"#YearsofService"]>=2) then "2 + Years" else "Less Than 2 Years")

Ryan ChongSoftware Team LeadCommented:
you may directly compare with " is null "? like this:
if [#"TermDate"] is null or [#"#YearsofService"] is null then "Less Than 2 Years" else  if([#"#YearsofService"]>=2) then "2 + Years" else "Less Than 2 Years"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Karen SchaeferBI ANALYSTAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.