C.functions
C.functions
To pass each student needs a grade of at least 5 and needs to be absent no more than 5 times. Use the IF function to fill colum
Use a combination of IF and AND to figure out for each student if they passed or not.
Use the IF function to fill columns D and E with ‘yes’ or ‘no’
testing
Example:
It’s possible to name cells and cell ranges. Then we can use the name as the cell reference instead of the column letter and row
- Name the cell B9 as ‘taxrate’
- Fill out cell C12 As ‘=B12*taxrate’
- Copy down the formula
- Name the range C12:C15 To ‘taxes’
- Insert the formula ‘=SUM(taxes)’
Exercise:
- Name the cell B24 ‘exchangerate’
- Use the cell name to calculate the ‘Value in MDL’
- Name the range C27:C36 ‘valuesMDL’
- Use the named range to calculate the average of ‘Value in MDL’
Average:
01/29/2025 3
testing
01/29/2025 4
TextFunctions
Exercise: Combine the following columns to creat serial numbers (the first has been done as an example)
Lookup the functions LEFT, RIGHT, and MID and use them to answer the following questions
My uncle went fishing on a beautiful Sunday.
Page 5
DateAndTimeFunctions
The value in cell B4 is the 12th of March 2020, eleven past 3 pm, and 5 seconds.
Use the following functions to get the day, month, year, hour, minute, second and weekday.
12-Mar-2021 15:11:05
DAY
MONTH
YEAR
HOUR
MINUTE
SECOND
WEEKDAY
Use WEEKDAY to complete column B in the following table. Then use conditional formatting to highlight the weekends.
(Hint: 1 = Sunday, 2 = Monday, 3 = Tuesday etc…)
Date Weekday
02-07-22
02-08-22
02-09-22
02-10-22
02-11-22
02-12-22
02-13-22
02-14-22
02-15-22
02-16-22
02-17-22
02-18-22
02-19-22
02-20-22
Page 6
ConditionalFunctions
Explanation: Conditions
We use IF to create a condition:
- IF has 3 parameters:
- The condition
- What to do in case the condition is met
- What to do in case the condition is not met
Example
'=IF(grade > 50%, “Pass”, “Fail”
Change the grade in B10 to test the function in C10
Grade: 60% Pass
Exercise
Use IF to fill out column C
Example
Here is a list of grades for both Peter and Paul. We use AVERAGEIF to calculate Paul’s average.
Student Grade
Peter 61%
Paul 72%
Paul 69%
Peter 58%
Paul 73%
Peter 59%
Exercise
The table below gives an overview over homeworks.
Page 7
ConditionalFunctions
3 4
Page 8
ConditionalFunctions
- Use COUNTIF to calculate how many times homework was handed in late
- Use SUMIF to addup the total number of exercises Jane has done.
- Use AVERAGEIF to calculate the average score of all homeworks that were handed in on time.
Page 9
LookupFunctions
INDEX
We use INDEX to look up a value from an grid. INDEX has three inputs.
INDEX(reference, row_num, column_num)
- reference: the grid
- row_num: the row value we are looking up
- column_num: the column value we are looking up (if left blank we look in the first row)
Example
d '=INDEX(B13:D15,2,1) returns the 2nd row and first column from the grid
I '=INDEX(B13:D15,3,3) returns the 3rd row and 3rd column from the grid
a b c
d e f
g h I
Exercise
Use INDEX to find the value in the first row and 2 nd column from the grid above
b
MATCH
MATCH searches for a specific value in a list, and returns it’s position
We can include a third parameter:
1: finds the closest value which is lower (only works if the list is in ascending order)
0 : only finds the exact value.
-1: finds the closet value which is larger (only works if the list is in descending order)
Example
1 '=MATCH("Bananas",A34:A38,0) returns 1 because "Bananas" is the first item in the list
3 =MATCH(42,B34:B38,1) returns 3 because 40 is the closest value which is lower
#N/A '=MATCH(39,B34:B38,0) returns an error because we are looking for an exact value, which doesn’t exist
2 '=MATCH(22,C34:C38,-1) returns 2 because 32 is the closest value which is larger
Exercise
Use MATCH to find the location of “Cucumbers”
Use MATCH to find the location of the first number before 44 in Count1
3
Page 10
LookupFunctions
Example
We want to lookup the price of Bananas
- The first parameter is “Bananas”. This is the value we are looking up.
- The second parameter is A70:C75 because that’s the table where we are looking up the values.
- The third parameter is 3, because that’s the column number where we find the price.
$5.00
We want to lookup the quantity of Apples
- The first parameter is “Apples”. This is the value we are looking up
- The second parameter is A70:C75 because that’s the table where we are looking up the values.
- The third parameter is 3, because that’s the column number where we find the quantity.
5
Exercise
Use VLOOKUP to find the quantity of Pineapples
2
Use VLOOKUP to find the price of Cucumbers
Example 2
The following table shows grade boundaries. We will use this table and VLOOKUP to assign the appropriate grade.
Mark Grade
0U
24 E
30 D
36 C
42 B
48 A
Exercise
Every week the price of oil changes.
Page 11
LookupFunctions
The following list shows the first Monday of every week in the first column, and the price of the oil in the second column.
Use VLOOKUP to find the price of oil for the following dates:
Exercise
Use the below table to lookup the price of Bananas
Page 12
NestedFunctions
Example 1
'=WEEKDAY(NOW()) 1-29-2025 8:41 4 4
The function NOW() gives the current date. This is called the output of the function.
The function WEEKDAY(…) uses the output of the function NOW() as an input.
In the example above, we say the function NOW() is nested in the function WEEKDAY(…)
Example 2
If Inga scores 75% or more on average, her dad will buy her a new iPhone.
Inga’s scores are listed in row 17
We can solve this in two ways:
1) Calculate the average first and then use an IF on the result
2) Use the AVERAGE function nested within the IF function (see cell )
Example 3
Nested IF
In case there are three possible outcomes it is often useful to use a nested IF
- If the score > 80% the student gets “Excellent”
- If the score is between 50% and 80% the student get a "Pass"
- If the score is lower than 50% the student get a "FAIL"
- Inspect the formula in B30 and change the value in A30 to test the formula
Score Feedback
85% Excellent Pass Excellent (not nested)
Excellent (nested)
Exercise
Test A Test B Test C
Jane 50% 60% 65%
John 43% 51% 45%
Jack 61% 65% 77%
Jaquelin 43% 41% 55%
Josh 80% 75% 76%
Students need an average of at least 50% on the Tests A and B, and at least 50% on Test C to pass. Solve using a non-nested approach and
(See the picture below for the expected solution)
Nested
Non-nested approach
approach
Page 13
NestedFunctions
Page 14
NestedFunctions
Jack
Jaquelin
Josh
Page 15
Exercise 1:
- Cell B7 can only be a product name
- Cell B8 can only be a month from January to June
- Create a function in B11 that will look up the value for the right product and month as specified in the table below
- If cells B8 and B9 are left empty we don't want an error message to show up
- HINT: combine the functions LOOKUP, MATCH and IFERROR
Results
Sales!
Product January February March April May June
Comic books 39 75 51 80 55 23
Computer games 75 77 35 11 11 13
Toys 75 67 27 49 32 12
Gaming consoles 100 40 89 76 50 87
Puzzels 25 62 67 38 73 68
Novels 60 18 99 26 88 28
Exercise 2:
In the list below the first two numbers represent the day, the second two numbers represent the month and the third two num
For example 250119 represents 25 January 2019.
Use DATE and MID to convert the numbers to a date format.
Format the cells to display the dates as dd mmmm yyyy e.g. 25 January 2019
120522
050419
191209
310101
150823
ed in the table below