0% found this document useful (0 votes)
21 views

C Functions

Uploaded by

Ross Derbyshire
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

C Functions

Uploaded by

Ross Derbyshire
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Number Grade Present

Grade of times high often Pass?


absent enough enough
Jeroentje 6.5 3 Yes Yes Pass
Klaas 5.5 3 Yes Yes Pass
Lars 7 5 Yes Yes Pass
Marietje 8 2 Yes Yes Pass
Marjolein 7.5 0 Yes Yes Pass
Pietje 6.5 4 Yes Yes Pass
Sarah 8 0 Yes Yes Pass
Sven 9 6 Yes No Fail

Use the Min function to find the lowest grade.


5.5

Use the Max function to find the largest absenteeism.


6

Use VLOOKUP to determine the grade of Lars.


7

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)’

Tax rate 15%

Product Cost Tax


6 x 4 frame $12.00 $1.80
5 x 7 frame $15.00 $2.25
10 x 8 frame $18.00 $2.70
12 x 8 frame $21.00 $3.15
$9.90

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’

Exchange rate: 10.1

Date Value in EUR Value in MDL


02-07-22 123 1242.3
02-08-22 42 424.2
02-09-22 124 1252.4
02-10-22 43 434.3
02-11-22 234 2363.4
02-12-22 24 242.4
02-13-22 91 919.1
02-14-22 566 5716.6
02-15-22 34 343.4
02-16-22 732 7393.2

Average: 2033.13

04/25/2024 3
testing

d of the column letter and row number.

04/25/2024 4
TextFunctions

Use & to combine the contents of two or more cells:


Example: hello there hellothere!

Exercise: Combine the following columns to creat serial numbers (the first has been done as an example)

Model ID Month Serial number


PMT 154 PMT154
PMT 124 PMT124
ADA 155 ADA155
PMT 511 PMT511
ADS 124 ADS124

Lookup the functions LEFT, RIGHT, and MID and use them to answer the following questions
My uncle went fishing on a beautiful Sunday.

- Use LEFT to get the first 8 letters of the sentence in A14. My uncle
- Use RIGHT to get the last 7 letters of the sentence in A14. Sunday.
- Use MID to get 4 letters from the sentence, starting from the 15 th letter. fish
- Use UPPER to get the whole sentence in uppercase values. MY UNCLE WENT FISHING ON A BEAUTIFUL SUNDA
- Use LOWER to get the whole sentence in lowercase values. my uncle went fishing on a beautiful sunday.
- Use FIND to find the where word in B22 can be found in the sentence. 15
fishing

Text to numbers and numbers to text


- The following numbers have been input as text. i.e. the spreadsheet does not recognize them as numbers.
- When we try to get the average we end up with an error message!
7 8 12 11 #DIV/0!

- Use VALUE to convert the texts to numbers


7 8 12 11 9.5

- Use INT to convert the texts to numbers


7 8 12 11 9.5

Page 5
TextFunctions

L SUNDAY.
y.

Page 6
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 12
MONTH 3
YEAR 2021
HOUR 15
MINUTE 11
SECOND 5
WEEKDAY 6

Day Month Year


Using DATE make a date value from cells C15 to E15. 12 4 1997
12 / April / 1997

Hour Minute Second


Using TIME make a time value from the cells C19 to E19. 15 11 5
3:11 PM

What time is it NOW?


4/25/2024 12:12

What WEEKDAY is it NOW? (Hint: combine two functions)


5

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 2
02-08-22 3
02-09-22 4
02-10-22 5
02-11-22 6
02-12-22 7
02-13-22 1
02-14-22 2
02-15-22 3
02-16-22 4
02-17-22 5
02-18-22 6
02-19-22 7
02-20-22 1

Page 7
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

Student Grade Pass / Fail


Jane 75% pass
John 49% fail
Jolly 50% fail
Jester 52% fail
Jill 81% pass
Jack 91% pass
Jake 65% pass

Explanation: Conditional Functions


We can combine conditions with some functions. We can count how many cells in row 26 have a value of greater than 2:
1 2 3 4 5 6 1 2
'=COUNTIF(A26:J26,”>2”)
6

We can do the same for SUMIF and AVERAGEIF


25
4.16666666666667

We can also use another cell for the condition:

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%

Paul’s average: 71%

Page 8
ConditionalFunctions

3 4

Page 9
ConditionalFunctions

Exercise
The table below gives an overview over homeworks.
- 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.

Student Grade Late? Exercises done


Jane 88% no 2
Mary 89% no 3
Louise 91% yes 2
Jane 92% no 1
Mary 75% yes 2
Louise 85% yes 3
Jane 82% yes 4
Mary 79% no 3
Louise 80% yes 2
0.87 5 7

Page 10
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

Product Count 1 Count2


Bananas 12 53
Apples 38 32
Strawberries 40 21
Cucumbers 45 16
Pineapples 55 14

Exercise
Use MATCH to find the location of “Cucumbers”
4
Use MATCH to find the location of exactly 40 in Count1
3
Use MATCH to find the location of the first number before 44 in Count1
3

VLOOKUP (Vertical Lookup)

Page 11
LookupFunctions

Page 12
LookupFunctions

We use VLOOKUP to lookup a value from a table.


We include the value which will determine the row for us.
We also include the column number, from where we will get the value we are looking up.
Like in MATCH, we can also add 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)
*Note: When looking up an exact value ALWAYS include the parameter 0

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

Product Quantity Price


Bananas 6 $5.00
Apples 5 $4.00
Strawberries 6 $34.00
Cucumbers 12 $5.00
Pineapples 2 $6.00

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

Student Mark Grade


1 49 A '=VLOOKUP(B94,$A$86:$B$91,2)
2 31 D '=VLOOKUP(B95,$A$86:$B$91,2)
3 37 C '=VLOOKUP(B96,$A$86:$B$91,2)

Page 13
LookupFunctions

4 25 E '=VLOOKUP(B97,$A$86:$B$91,2)
5 45 B '=VLOOKUP(B98,$A$86:$B$91,2)

Exercise
Every week the price of oil changes.
The following list shows the first Monday of every week in the first column, and the price of the oil in the second column.

Week Oil price (USD per Barrel)


3. Jan. 2022 $92.30
10. Jan. 2022 $95.30
17. Jan. 2022 $96.12
24. Jan. 2022 $91.48
31. Jan. 2022 $90.22
7. Feb. 2022 $89.98
14. Feb. 2022 $97.21

Use VLOOKUP to find the price of oil for the following dates:

Date Oil price (USD per Barrel)


4. Jan. 2022
27. Jan. 2022
15. Feb. 2022
6. Feb. 2022
1. Feb. 2022
14. Jan. 2022
17. Jan. 2022

HLOOKUP (Horizontal lookup)


HLOOKUP is exactly the same as vlookup, but we lookup up a certain column value, instead of a row value

Exercise
Use the below table to lookup the price of Bananas

Cucumbers Apricots Bananas Grapes Peaches Plums


Quantity 4 6 2 6 5 4
Price $2.40 $2.20 $3.10 $3.20 $1.20 $3.10

Page 14

You might also like