Tarraxippus
Tarraxippus

Reputation: 11

Formula parse error in Google Sheets - using IF statement along with multiple 'OR' statements

Trying to create a spreadsheet to keep track of levels on a game (brawlhalla), and when trying to create a formula, I kept coming across the error stated in the title

The formula is as follows: =IF((J2="Ada") OR(K2 = "Ada") OR(L2 = "Ada") OR(M2 = "Ada") Or(N2 = "Ada") OR(O2 = "Ada"),"Y","N")

Thanks in advance

Upvotes: 1

Views: 1912

Answers (1)

Tom Sharpe
Tom Sharpe

Reputation: 34255

I can see where you're coming from because in most programming languages (including Ada?) putting OR between two expressions works, but not in an Excel or Google Sheets spreadsheet formula, you have to put

=if(OR(J2="Ada",K2="Ada",L2="Ada",M2="Ada",N2="Ada",O2="Ada"),"Y","N")

If it's a continuous range, there are shorter ways of doing it like

=IF(ISNUMBER(MATCH("Ada",J2:O2,0)),"Y","N")

or

=IF(COUNTIF(J2:O2,"Ada"),"Y","N")

The nearest equivalent to the original formula (since there are no logical operators) is

=IF((J2="Ada")+(K2="Ada")+(L2="Ada")+(M2="Ada")+(N2="Ada")+(O2="Ada"),"Y","N")

which exploits the fact that a TRUE value equates to 1 when used in an arithmetical expression.

Upvotes: 2

Related Questions