0% found this document useful (0 votes)
65 views10 pages

Functions Sample

The document discusses the IF, nested IF, and VLOOKUP functions in Excel. The IF function allows for conditional logic with three arguments - a logical test, value if true, and value if false. Nested IF is used when more than two outcomes are needed by nesting additional IF statements. VLOOKUP is used instead of nested IF when there are many outcomes, as it searches a table vertically to return a value. It takes the lookup value, table array, column index number, and optional range lookup argument. The examples demonstrate using these functions to return values or text based on conditional criteria for sales commissions, student grades, and other business scenarios. Tables and absolute references are important for

Uploaded by

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

Functions Sample

The document discusses the IF, nested IF, and VLOOKUP functions in Excel. The IF function allows for conditional logic with three arguments - a logical test, value if true, and value if false. Nested IF is used when more than two outcomes are needed by nesting additional IF statements. VLOOKUP is used instead of nested IF when there are many outcomes, as it searches a table vertically to return a value. It takes the lookup value, table array, column index number, and optional range lookup argument. The examples demonstrate using these functions to return values or text based on conditional criteria for sales commissions, student grades, and other business scenarios. Tables and absolute references are important for

Uploaded by

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

Simple IF

IF function: (Two outcomes)


This is a function that uses logical test to decide on action to be taken
Syntax
IF(logical_test, value_if_true, value_if_false)

1. It is made of three arguments as shown below:-

 Logical test: Comparison between two values using logical operators


= Equal to
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
<> Not equal to

B2>100000 as shown in figure above


The out come is either TRUE or FALSE

 If _TRUE an action is performed (in this figure above the action is to write
"Engineer" in cell B2)
 If_ FALSE another different action is performed (in this figure above the action is to
write "Worker" in cell B2)

Example 1:
A salesman is paid a commission on sales. He receives 5% if his sales on sales less than 1000
and 10% if his sales on sales 1000 or more. Use IF function to calculate the amount of
commission he receives:
A B
1 Sales Commission
2 1500 =IF(A2<1000;A2*0.05;A2*0.1)
3 2000
4 900
5 1200
6 950
Condition: Sales<1000
True Path Sales*0.05
False Path Sales*0.10
Example 2:
Students are awarded a PASS if they obtain 60 or more marks in a test. Use function IF to enter
the correct result.

A B C
1 Student Marks Result
2 Ahmed 80 =IF(B2<60;”FAIL”;”PASS”)
3 Samir 40
4 Naji 50
5 Hamad 35
Condition: Marks<60
True Path “FAIL” (Text must be enclosed within double quotes)
False Path “PASS” (Text again enclosed within double quotes)

The Nested IF
Nested IF - More Than Two Outcomes
We use nested if when we have more than two outcomes. As an example we will look back on
example 2 above. If I need to grade the students marks as
Less than 60 grade F
60 – 69 grade D
70 – 79 grade C
80 – 89 grade B
90 and better grade A
There are more than 2 outcomes which means I have to test (using IF function) for grade A, B,
C, D, and F
So I simply apply If function as follow
IF (Marks >= 90, "A", IF (Marks>=80, "B", IF (Marks>=70,"C", IF (Marks>=60,"D","F"))))

First IF Second Third Fourth


Where IF IF IF
 Marks is cell B2
 For First IF- logical test outcome TRUE – Value_if_true becomes A
FALSE – Value_if_false becomes Second IF function
 For second IF- logical test outcome TRUE – Value_if_true becomes B
FALSE – Value_if_false becomes Third IF function
 For third IF- logical test outcome TRUE – Value_if_true becomes C
FALSE – Value_if_false becomes Fourth IF function
 For fourth IF- logical test outcome TRUE – Value_if_true becomes D
FALSE – Value_if_false becomes F

Note Fourth IF test only the last two out comes (no needs for extra test)

Rule 1 in a nested if number of IF functions = Number of outcomes – 1

Rule 2 Use the function arguments dialog (you access that by chosen fx then choose logical -
from category then choose IF)

Rule 3 on the Value_if_false where you need to insert an IF function


 Click in the Value_if_false field first and
 Just choose the IF shown on the left hand side next to formula bar or
 Write in the formula bar before the last closing bracket a "," or ";" depending on what
shows up in the help tip then type IF followed by "(" the dialog will turn into new IF
function argument dialog.

Exercise 1 (IF function)

A B C D E
1 Name District Sales Emp. Yrs Job Level
2 Linda East 20000 2
3 Joe West 42302 9
4 Bill East 53001 3
5 Mary South 12000 12
6 Mark South 2050 6
7 John North 9000 0
8 Ted East 40000 4

1. Prepare the CALC worksheet as the above. Save as YourName_1.xls


2. In cell E2, find out the Job Level for each employee.
If the Emp.Yrs is more than or equal to 5 years, then the Job Level is Senior.
Else if it is less than 5 years, then Job Level is Junior.
Exercise 2 (Nested IF)

Prepare the CALC worksheet as shown below

1. Insert the following columns after columns C.

Cost/Car
5400
6600
7200
10500

2. Total cost = QTY* Cost/Car.


3. Tax (column F) is calculate as 0.15 of Total cost
4. Use Nested if to calculate profit as follow
IF Car Code is 1 then profit is 33% of Total Cost - Tax
Else IF Car Code is 2 then profit is 35% of Total Cost- Tax
Else IF Car Code is 3 then profit is 38% of Total Cost-Tax
Else Profit is 40% of Total Cost- Tax
5. Format Columns E, F, and G as Currency $ with 1000 Comma separator, and one
decimal place.
6. Merge and center cells A to G in row 1, add yellow color shade.
7. Add Thick Borders around the merged cells A1:G1.
8. Change the width of columns D to 14.
9. Using the appropriate function: calculate the Totals in cells D8,E8, and G8
10. Calculate in cells E10, E11, and E12.

 How many Car types Produced


 Highest Total
 Lowest Profit
11. Add Thick borders to cells A3:G7.
12. For row 3 fill cells with light blue color.
13. Insert the current date that change automatically in cell A2.
14. Prepare your worksheet for printing with the following requirements.
 Orientation: Landscape
 Scaling: Fit to one page.
 Center page vertically and horizontally.
 Add Header: File Name on the left section, your name on the center section
and current date on the right section. Change the font size of your name to 14
and Bold.
 Footer: Page number on the center section

15. Rename sheet 1 as Car.


16. Make a copy of sheet car and rename it as final_sheet.
17. Save your work as CarMan.XLS

VLOOKUP Functions

If the number of outcomes in the Nested IF is large (Ex: 20 outcomes or more) the statement
would become too complex. VLOOKUP function is used instead, where data are put in a table
and we search the table vertically.

Syntax

VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)

Lookup_value is the value to be found in the first column of the table_array.

Table_array is the table of information in which data is looked up. Absolute value must be
used for the Table Array in order to copy down the formula

Col_index_num is the column number in table_array from which the matching value must be
returned. A col_index_num of 1 returns the value in the first column in table_array; a
col_index_num of 2 returns the value in the second column in table_array, and so on.

Range_lookup is a logical value that specifies whether you want VLOOKUP to find an exact
match or an approximate match.

Example 1: Finding Students grade


If Range_lookup was TRUE or omitted, an approximate match is returned. In other words, if an
exact match is not found, the next largest value that is less than lookup_value is returned. For 67
we will get D

Example 2

If Range_lookup was FALSE (0), VLOOKUP will find an exact match.


Result is
75
55
150

If one value is missing the following will occur

A B
1 Item Price
2 Shoes =VLOOKUP(A2;$A$7:$B$9;2)
3 Jacket
4 Dress
5
6 Table
7 Jacket 150 Table array
8 Shirts 55 A7:B9
9 Shoes 75
10

Note that we used absolute value for the Table Array in order to copy down the formula in the
Price column. The results for the three inputs will be: Dress is not in the table

Shoes 75
Jacket 150
Dress #N/A

Exercise 1 Vlookup

Prepare your worksheet sheet 1 as shown below:


Note sheet 2 should have Total Sales < $50,000 in cell A1 and in cell B1 3%
Total Sales ≥ $50,000 in cell A2 and in cell B2 4%
1. Center "ABC" across columns A through F. Change its font size to 16, Bold and font
color to Dark Blue. Change background color of the cell to Yellow.

2. Adjust the column widths when necessary. Perform the following:


a. Use IF function to calculate the commission in cell D4. The commission is based
upon the salesperson's sales.
Note: use value from sheet 2
Note: use cell address not value

If Total Sales less than $50,000, Commission = Total Sales * 3%


If Total Sales more than or equal to $50,000, Commission = Total Sales * 4%.
Copy the formula to D5 through D10.

b. Using the formula below, calculate the Total Salary in column D.


Total Salary = Salary + Commission.

c. Use Nested if to fill in evaluation criteria in Evaluation column according to


evaluation table.
d. Use Vlookup to fill in evaluation criteria in Evaluation column according to
evaluation table.

e. Use the appropriate function to calculate the following:


i. Average Salary in cell E14
ii. Highest Total Salary in cell E15
iii. Lowest Total Salary in cell E16
iv. Number of Salesperson in cell E17
v. Number of person whose Total Salary is more than $100,000 in cell E18.
f. Format all numeric values to currency with 0 decimal places. (E.g. 12.0 formatted
as $12).

g. Insert a row between row 9 and 10. Type in your name as the salesperson in this
new row. Enter 92000 for the total sales and 50000 for base salary. Copy the
appropriate formulas into Commission, Total Salary and Salesperson's
Evaluation.

h. Save your file and close the program.

Compound IF

COMPOUND STATEMENT
 The AND and OR functions can be used if there is more than one condition to be applied
onto the IF function.
 AND Connector (function):

Condition 1 AND Condition 2 Out Come


T T T
T F F
F T F
F F F

Condition 1 & 2 is a logical test EX. A1>10.

 AND(logical_test1, logical_test2) – each logical test will produce a T(True) or a


F(false) the out come of AND connector will be according to AND table above.

 This Compound statement can be used in IF statement when we need to test more than
one condition. EX. IF(AND(logical_test1, logical_test2), value_if_true, value_if_false)

 OR Connector (Function):
Condition 1 OR Condition 2 Out Come
T T T
T F T
F T T
F F F
 OR(logical_test1, logical_test2) – each logical test will produce a T(True) or a
F(false) the out come of OR connector will be according to OR table above.
EX. IF(OR(logical_test1, logical_test2), value_if_true, value_if_false)
Exercise 1 (Compound IF functions) – AND
1. Prepare the CALC workbook as below. Save as YourName_2.xls
Retirement Schedule

Name Age 50-60 61-65 Over 66


Ali 50
Ahmad 58
Mariam 60
Sayed 63
Aisha 67
Noor 70

The problem:
 A person is categorized under 50-60 if his/her age is more than 55 and less and
equal to 60.
 Display the result as Yes in C4 if he/she is within the category and display No if
he/she is not under the category.

Exercise 2 (Compound IF functions) – OR


Prepare the following work sheet

The problem
1. A person is given
10% commission if
His age > 35 or Years worked >=15
5% commission if
His Age > 30 or years worked > 5
Otherwise his commission is Zero

2. Calculate in column commission the commission for each person.

You might also like