Multiple IF statements

Discuss the spreadsheet application

Multiple IF statements

Postby AliGee » Thu Nov 21, 2019 2:06 pm

Have spent considerable time just trying to work out how to enter a 'simple' function which is to return a varying value as follows :-

Sorry unable to paste or create a table here.

•  A  B  C                 
1 F A Desired Value
2 2 1 3 Where column A is greater than column B
3 1 1 1 Where column A is equal to column B
4 1 2 0 Where column A is less than column B

Is there any way to integrate the three functions into one formula - any advice would be most appreciated :crazy:
Last edited by MrProgrammer on Thu Nov 21, 2019 5:42 pm, edited 1 time in total.
Reason: Created aligned table for OP
Open Office 3.4 , Windows 7
AliGee
 
Posts: 3
Joined: Tue Nov 19, 2019 11:38 am

Re: Multiple IF statements

Postby robleyd » Thu Nov 21, 2019 2:34 pm

In column C:
Code: Select all   Expand viewCollapse view
IF( A1>B1; 3; IF(A1=B1; 1; 0 ) )


In pseudocode that is
IF
value of A1 is greater than B1, display 3
Else IF
value of A1 is equal to B1, display 1
Else
[A1 must be less than B1] display 0
Cheers
David
Apache OpenOffice 420m2(Build:9821) - Slackware 14.2 - 64 bit
LibreOffice 6.0.7.3 - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
robleyd
Moderator
 
Posts: 3206
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Multiple IF statements

Postby Villeroy » Thu Nov 21, 2019 3:14 pm

Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 27901
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Multiple IF statements

Postby MrProgrammer » Thu Nov 21, 2019 6:14 pm

AliGee wrote:• A B C
1 F A Desired Value
2 2 1 3 Where column A is greater than column B
3 1 1 1 Where column A is equal to column B
4 1 2 0 Where column A is less than column B

Is there any way to integrate the three [cases] into one formula?
=CHOOSE(2+SIGN(A2-B2);0;1;3)

[Tutorial] How do I specify the formula for a column?

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.

[Tutorial] Ten concepts that every Calc user should know
Mr. Programmer
AOO 4.1.7 Build 9800 on MacOS 10.14.6.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
MrProgrammer
Moderator
 
Posts: 3951
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA


Return to Calc

Who is online

Users browsing this forum: MSN [Bot] and 31 guests