ALTERYX INSPIRE | Join us this May for for a multi-day virtual analytics + data science experience like no other! Register Now
The Alteryx Community will be temporarily unavailable for a time due to scheduled maintenance on Thursday, April 22nd. Please plan accordingly.

Alteryx Analytics Hub

Find answers, ask questions, and share expertise about Alteryx Analytics Hub.

Error in If statement

MB_Rocks
6 - Meteoroid

if contains(Month,"February") and if contains(Year,"2020") then "02-01-2020"
elseif contains(Month,"February") and if contains(Year,"2021") then "02-01-2021"
end

This is I'm using in multi row formula option 

Plse help me with the code 

 

It resolved Thanks Team 

mbarone
15 - Aurora
15 - Aurora

if contains(Month,"February") and if contains(Year,"2020") then "02-01-2020"
elseif contains(Month,"February") and if contains(Year,"2021") then "02-01-2021"
end

 

I tend to use boolean instead of if/then/else.  So here's how I'd do it:

IIF(Contains([Month],'February') && Contains([Year],'2020'),'02-01-2020',

IIF(Contains([Month],'February') && Contains([Year],'2021'),'02-01-2021',

Null() ))

 

That can easily be translated to if/then/else, but I think what you're missing is the final condition where both your IF statements fail.