if-statementlibreofficelibreoffice-calc

Can I use OR in LibreOffice calc IF statement?


I'm trying to achieve something like:

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

Or, in pseudo 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.


Solution

  • 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.