How can I write an if then statement which has multiple conditions in it? I tried using || instead of "or" but it didn't work. Is there any way to write this logic?
For eg:
if site name = "Yahoo" OR "Google"
then "X"
Elseif site name = "CNN" OR "CBS"
then "Y"
ELSEIF "Z" endif
Solved! Go to Solution.
if [site name] = "Yahoo" OR [site name] = "Google" then "X" ELSEIF [site name] = "CNN" OR [site name] = "CBS" then "Y" ELSE "Z" ENDIF
Think of the "OR" as an operator on two logical statements, so the code before and after should each evaluate to TRUE or FALSE
I'm not at my computer, but you can certainly do something like
IF [siteName] == "Google" OR [siteName] == "Yahoo" THEN
... you could also check for IN... e.g.
IF [siteName] IN ("Google","Yahoo") THEN
Worth considering the SWITCH statement as well:
SWITCH([site name],"Z", ."Yahoo","X" ,"Google","X", ,"CNN","Y", ,"CBS","Y" )
Too many commas in my formula. Fixed version:
SWITCH([site name],"Z" ,"Yahoo","X" ,"Google","X" ,"CNN","Y" ,"CBS","Y" )
(Shouldn't have written it on a mobile!)
In this case and in a lot of other cases Switch formula is better and it is shorter.
I want to do something similar to this, but use the contain formula as the field may have other information as well. So I tried the following, but it does not bring out the results I'm expecting...
if contains("Yahoo",[site name]) OR contains("Google",[site name]) then "X" ELSE "Z" ENDIF
I am having the same issue as well. Does anyone have a resolution?