16

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.

3
  • Why the -1? If the wrong Stack Exchange site, which should I be using? It's a clear question isn't it?
    – DaFoot
    Nov 11, 2014 at 19:04
  • I could be wrong, but I believe the person who down-voted saw your question as not having enough research before you posted your question. If you read this page, it might help you understand the down-voting system: Click Here.
    – Aterxerxes
    Nov 11, 2014 at 21:52
  • 1
    Guess it must be that. Though how you find the or() function when you don't know it exists isn't easy if expecting OR to be an operator. Try searching for if with or. ;)
    – DaFoot
    Nov 19, 2014 at 11:00

1 Answer 1

30

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.