0
votes

Do Google Sheets have a || operator like most of the languages?
I'm trying to use it inside a switch function to nest some values.

=SWITCH(G5;"BLACKOLIVES";"BLACK";"JABOTICABA";"BLACK";"MULLBERIES";"BLACK")

this is how I'm doing it now, I want to do it somewhat like whats next

=SWITCH(G5;"BLACKOLIVES"||"JABOTICABA"||"MULLBERIES";"BLACK") 

but this statement returns an error and I can't find a ||-like operator in the documentation.

Does anyone have an idea how to solve this?

2
Not sure what you mean "like most languages". In different languages this operator can do different things, and if you mean something like the logical OR operator here, it doesn't make sense to apply to strings. What do you want to happen? - ttarchala
i want it to do this if G5 is "BLACKOLIVES" or "JABOTICABA" or "MULLBERIES" then cell receives "black" without going G5:"BLACKOLIVES";"BLACK";"JABOTICABA";"BLACK" - João Vitor Ramos Rodrigues
Then use IF or IFS(OR()..) instead of SWITCH(), or if you have many such options, a translation table with a VLOOKUP() - ttarchala

2 Answers

0
votes

Maybe you could use something like

=if(regexmatch(G5, "BLACKOLIVES|JABOTICABA|MULLBERIES"),"BLACK",)

In regular expressions the "pipe"-character means 'or'...

0
votes

an alternative syntax would be:

=IF(OR(G5="BLACKOLIVES", G5="JABOTICABA", G5="MULLBERIES"), "BLACK", )