Page 1 of 1

Multiple IF statements

PostPosted: Thu Nov 21, 2019 2:06 pm
by AliGee
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:

Re: Multiple IF statements

PostPosted: Thu Nov 21, 2019 2:34 pm
by robleyd
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

Re: Multiple IF statements

PostPosted: Thu Nov 21, 2019 3:14 pm
by Villeroy

Re: Multiple IF statements

PostPosted: Thu Nov 21, 2019 6:14 pm
by MrProgrammer
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