Can I use OR in LibreOffice calc IF statement?

DaFoot picture DaFoot · Nov 11, 2014 · Viewed 18.2k times · Source

I'm trying to achieve something like:

=IF( N2="string1", "high", IF( N2="string2" or N2="string3","middle","low") )

Or, in psuedo code:

String input = <some value>
if( input.equals("string1") ) {
     return "high"
} else if ( input.equals("string2) || input.equals("string3") ) {
    return "middle"
} 
return "low"

Any idea how I can do that using a spreadsheet (Libre Office Calc ideally) formula rather than code? Where the input variable would obviously be a cell reference.

Answer

Aterxerxes picture Aterxerxes · Nov 11, 2014

Using your example of "N2" as the cell reference, the formula would be the following:
=IF( N2="string1", "high", IF( OR(N2="string2",N2="string3"),"middle","low") )
If you would like to read up on the "OR" Function in Libre Office, you can click here.
Please let me know if that doesn't work.