0% found this document useful (0 votes)
50 views14 pages

Computer - Excel Logical Functions

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views14 pages

Computer - Excel Logical Functions

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

COMPUTER C

EXCEL- LOGICAL
FUNCTIONS
Assoc. Prof. Dr. Seda Ersus
Dr. Burak Altınel
Dr. Burcu Öztürk Kerimoğlu
IF FUNCTION
The IF function, one of the logical functions in
excel, checks whether a condition is met and
returns one value if TRUE and another value if
FALSE.
Syntax: =IF (logical_test; [value_if_true];
[value_if_false])
 logical_test (required) = the condition you want to
test.
 value_if_true (required) = the value that you want
returned if the result of logical_test is TRUE.
 value_if_false (optional) = the value that you want
returned if the result of logical_test is FALSE.
Examples:
➢ Cell D values:
If the value of cell
C1 is equal to 0,
the value is equal
to 1, otherwise it
is equal to 2.
=IF(C1=0;1;2)
➢ If the value of A2 is greater than B2, the number is over
the budget, otherwise it is ok.
=IF(A2>B2;"Over Budget";"OK")

 If the cell A4 is equal to 500, the value is the difference


between B4 and A4 cells, if not, leave the cell blank.
=IF(A4=500;B4-A4;" ")
ATTENTION!
Equal to: =
Greater/bigger than: >
Less/smaller than: <
Greater than or equal to: >=
Less than or equal to: <=
AND FUNCTION
AND function is a logical function used to require more than
one condition at the same time. AND returns either TRUE or
FALSE. The AND function can be used as the logical test
inside the IF function to avoid extra nested IFs, and can be
combined with the OR function.
=AND (logical1; [logical2]; ...)
Examples:
➢ To test if the value in A1 is greater than 0 and
less than 5
=AND(A1>0;A1<5)

➢ A2 contains "Days", and B2 is greater than or


equal to 30, and B2 is greater than C2.
=AND(A2="Days";B2>=30;B2>C2)
OR FUNCTION
As well as AND, the Excel OR function is a basic logical
function that is used to compare two values or statements.
The difference is that the OR function returns TRUE if at
least one of the arguments evaluates to TRUE, and returns
FALSE if all arguments are FALSE.
=OR (logical1; [logical2]; ...)
Examples:

➢ A2 contains "apples" or "oranges"


=OR(A2="apples";A2="oranges")

➢ The number of the courses (B8) are smaller than 25 or


total credits (C16) is greater than or equal to 4.
➢ =OR(B8<25;C16>=4)
Using nested if functions in a formula
 Using a function as one of the arguments in a formula
that uses a function is called "nesting", and we’ll refer
to that function as a "nested function".
 Nested IF functions work by replacing one or both of
the TRUE/FALSE calculations with another IF function.
Usually, nested IFs are used when you need to test
more than one condition and return different results
depending on those tests.

If A1 is greater than or equal to 15 and B1 is greater than


3, the value is correct, if not, it is incorrect.
=IF(AND(A1>=15; B1>3);”Correct”;”Incorrect”)
 For example, imagine you have a sales team of four people,
and you need to calculate their commission for the month
based on their sales.
 Your commission plan works as follows:
If someone sells less than $400 in a month, they get 7% commission.
For sales between $400 and $750, they get 10% commission.
For sales over $750, they get 12.5%.
 Rather than calculate each of these commission figures individually, you decide to use a
nested IF formula instead. The logical tests you would use in this case are these:
1. Is commission less than $400? If TRUE, then calculate commission.
2. If FALSE, then is commission less than $750 and greater than or equal to $400. If TRUE
then calculate commission.
3. If FALSE, then calculate commission (because it must be more than $750 - we don't
need to do another logical test for this).
 The formula to represent this to calculate commission looks like this:
=IF(B4<400;B4*0,07;IF(AND(B4<=750;B4>=400);B4*0,1;B4*0,125))
The logic for assigning a grade goes like this:
To build up a nested IF formula that reflects this logic, we start by testing to
see if the score is below 64. If TRUE, we return "F". If FALSE, we move into
the next IF function. This time, we test to see if the score is less than 73. If
TRUE, we return "D". If FALSE, we move into yet another IF function. And so
on.
Eventually, the formula we have in cell looks like this:

Score (cell C5) Grade


0-63 F
64-72 D
73-84 C
85-94 B
95-100 A

=IF(C5<64;"F";IF(C5<73;"D";IF(C5<85;"C";IF(C5<95;"B";"A"))))

You might also like