Logical Functions - If and or
Logical Functions - If and or
IF
WHY YOU NEED TO KNOW THIS?
SYNTAX
=IF(Condition,ActionIfTrue,ActionIfFalse)
The Condition is usually a test of two cells, such as A1=A2
ActionIfTrue and ActionIfFalse can be numbers, text or calculations
EXAMPLE
B
Name
Shekhar
Gagan
Bala
3
4
5
6
C
Sales
1000
6000
2000
D
Target
5000
5000
4000
E
F
G
H
Result
Not Achieved =IF(C4>=D4,"Achieved","Not Achieved")
Achieved
=IF(C5>=D5,"Achieved","Not Achieved")
Not Achieved =IF(C6>=D6,"Achieved","Not Achieved")
AND
WHY YOU NEED TO KNOW THIS?
This function tests two or more conditions to see if they are all true
It can be used to test that a series of numbers meet certain conditions
It can be used to test that a number or a date falls between an upper and lower limit
Normally the AND() function would be used in conjunction with a function such as =IF()
SYNTAX
=AND(Test1,Test2)
Note that there can be up to 30 possible tests
When used by itself it will show TRUE or FALSE
EXAMPLE
C
D
Items To Test
500
800
500
25
25
500
12
3
4
5
6
7
E
Result
TRUE
FALSE
FALSE
TRUE
=AND(C4>=100,D4>=100)
=AND(C5>=100,D5>=100)
=AND(C6>=100,D6>=100)
=AND(D7>=1,D7<=52)
OR
WHY YOU NEED TO KNOW THIS?
This function tests two or more conditions to see if any of them are true
It can be used to test that at least one of a series of numbers meets certain conditions
Normally the OR() function would be used in conjunction with a function such as =IF()
SYNTAX
=OR(Test1,Test2)
Note that there can be up to 30 possible tests
When used by itself it will show TRUE or FALSE
EXAMPLE
3
4
5
6
7
Order No.
K1
K2
K3
K4
Cost
1000
1000
2000
5000
E
F
Payment Handling
Type
Charge
Cash
$0
Visa
$5
Cheque
$0
Mastercard
$5
=IF(OR(E4="Visa",E4="Mastercard"),5,0)
=IF(OR(E5="Visa",E4="Mastercard"),5,0)
=IF(OR(E6="Visa",E4="Mastercard"),5,0)
=IF(OR(E7="Visa",E4="Mastercard"),5,0)