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.

DaFoot
  • 1,475
  • 8
  • 29
  • 58
  • 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 '14 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.](http://stackoverflow.com/help/privileges/vote-down) – Aterxerxes Nov 11 '14 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 '14 at 11:00

1 Answers1

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.

mmoya
  • 1,901
  • 1
  • 21
  • 30
Aterxerxes
  • 554
  • 4
  • 13