Sie sind auf Seite 1von 4

Excel Functions: -

(http://www.excel-

exercise.com)

IF Function:
The IF function needs 3 parameters

The test
The result if the test is TRUE
The result if the test is FALSE

=IF(test,if test is TUE,if test is FALSE)

If you want to display text inside a cell, you must write the result of the True and False parameter between double quote.
=IF(test,"Pass","Fail")

It's also with the symbol double-quote that you can express an empty string. If you omit the third parameter and the result
of your test is false, Excel will display FALSE inside your cell. So, to avoid this, it is better to write "" instead of nothing.
=IF(test,"Pass","")

For numbers or formulas, you must write your second and third parameters without double-quote.
=IF(test,A1-B1,A1-C1)

The first parameter of the IF function is a logical test. A logical test compares 2 data. You can have these possibilities:

Example
Imagine the case of the result of a football match. You want to display Win or Lose when the team in column A has a better
result than the team in column D
For the cell E2, you will write
=IF(B2>C2,"Win","Lose")

But, as you know, it is also possible to have a draw. So, you must manage not 2 but 3 states with your IF function.
To solve this, you must include another IF function inside your first IF function. In your first function, you replace the first
False parameter by your second IF function. So the cell E2 becomes:
=IF(B2>C2,"Win",IF(B2<C2,"Lose","Tie"))

Fill the following spreadsheet

In column E, you have the average result for each students for an exam. In column F, write a function which returns if the
students Pass or Fail if the average mark is greater or equal than 10.
Change your function to display

Fail (when the average is below 10)


Pass (when the average is between 10 and 12)
Good (when the average is between 12 and 14)
Very Good (when the average is between 14 and 16)
Excellent (when the average is beyond 16)

=IF(E2<10,"Fail",IF(E2<12,"Pass",IF(E2<14,"Good",IF(E2<16,"Very Good","Excellent"))))

Exercise: Management of the stocks


You manage inventory and orders of a company. You cannot honor the orders if you do not have the full amount requested.
So you create an IF function that will check that you have the quantity in your stock. If your stock is lower, you can not
deliver the amount you have.
For example you can write the following function:
=IF(C3<B3,C3,B3)

For the second part of the exercise, you initiate an order with your suppliers if you could not fulfill the entire order. You can
write the formula in different ways for an equivalent result

=IF(D4<B4,B4-D4,"")

Or

=IF(D4=C4, B4<D4,"")

AND OR functions:-

These functions are often attached to the IF function but can also be used with the tools of data validation or conditional
formatting updates

AND function
A condition AND returns TRUE if and only if all tests in the parenthesis are true.
=AND(test 1,test 2,test 3, ...)

OR function

A condition OR returns TRUE if one (or more) tests of the function is true.
= OR(test 1,test 2,test 3, ...)

Excel 2010 allows up to 255 arguments in the functions AND & OR

Exercise
In the following file, you have various information about your customers. You want to extract of this file a part of your
customers on certain criteria.
If the criteria match your expectations, you will enter in column G 1 if you rest is True and 0 if test is not conclusive. Then,
you make a SUM of the column G to see how many customers match your criteria.
Try to solve all these issues in the Excel workbook below.

Question 1: How many clients are married with one child


Question 2: How many clients are single or divorced
Question 3: How many clients are married with an income above 75,000

Question 4: How many clients are male, unmarried and without children
Question 5: How many clients are women with 1 or 2 children
Question 6: How many clients are married or in relationship, with an income greater than or equal to 50,000 and have at least two children.

Name
JONAS
SAMEN
SATAKE
LEON
BYERLY
WARNER
GAUDEFROY
CHAPMan
SIMPSON
FORDYCE
TORTELLI
ADCOCK
CONTAT
ZIZZARI
FREYERMUT
H

First Name
Lee
Michael
Kaori
Fernando
Kimberly
Norris
Marie-Claire
Mathew
Aubrey
David
Olavo
David
Thibault
Stephen
Jean-Luc

Genre
Man
Man
Man
Man
Woman
Man
Woman
Woman
Man
Man
Woman
Woman
Man
Woman
Man

Income
35000
77000
70000
23000
97000
26000
89000
77000
34000
61000
27000
72000
85000
84000
50000

Situation
Relationship
Single
Married
Single
Relationship
Divorced
Relationship
Single
Divorced
Relationship
Single
Divorced
Relationship
Single
Single

Children
0
0
3
3
1
3
0
2
0
2
0
3
1
3
2

JONES

David

Man

31000

Single

Result

The answer for the question 1 is:


=IF(AND(E2="Married",F2=1),1,0)

The answer for the question 2 is:


=IF(OR(E2="Single",E2="Divorced"),1,0)

The answer for the question 3 is:


=IF(OR(E2="Married",D2>75000),1,0)

The answer for the question 4 is:


=IF(AND(C2="Man",E2="Single",F2=0);1;0)

The answer for the question 5 is:


=IF(AND(C2="Woman",OR(F2=1,F2=2));1;0)

The answer for the question 6 is:


=IF(AND(D2>=50000,F2>=2,OR(E2="Married",E2="relationship"))1,0)

COUNTIF

When you are trying to count the number of times you have a name, a date, a value in a list, only the function COUNTIF
should be used.
The function COUNTIF requires only two parameters

the range of cells where is your data


the value you search.

=COUNTIF(Range of cells, research)

Example
In the following table, you have a shopping list of equipment and want to know how often you sale CD-ROM.

Das könnte Ihnen auch gefallen