COMP 102 2025 - Lecture Six
COMP 102 2025 - Lecture Six
General Information
Lecturer: Malatsi GALANI
[[email protected]]
Online Resource: COMP 102 via EDUHUB
[Moodle]
Lab Practical: Starts 2nd Week
Please interrupt with questions at any time
Problem-Solving Concepts and Principles
in MS Excel – Advanced Functions
Lecture Outline
1. What are functions
2. Simple Syntax of Commonly
Used Functions
3. Different charts and Graphs
4. Uses of charts and Graphs
to analyse data
RECAP
1. There is a formula =A1+B1 in cell C1, and cells A1 and B1 contain numbers 2 and 3
respectively. What will be the new formula when the formula is copied to cell C2?
a. =A2+D2
a.=C2+B2
b.=C1+D1
c.=A2+B2
2. When calculating in MS Excel using the formula =6+(4/2), what is the answer?
d.5
e.8
f.12
g.7
3. If you copy the formula =$B38 into another cell, the result will be
a. The column part will remain the same
b. The row part will remain the same
c. Both the column and row will remain the same
d. Both will change
10. When you accidentally make the error of typing the letter the letter "o" instead of a zero in
a formula, MS Excel 2013 will display……
e. #ERROR!
f. #VALUE!
g. #LABEL!
h. #NAME!
Excel Built-In Function Categories
Text, Logical, Date and Time
Lookup and Reference
Mathematical, Statistical, Financial
Database, Engineering,
Web Information, Cube
Mathematical Functions
Used to perform various arithmetic operations such as:
Adding the values in a range of cells
Finding the average of selected cells, etc.
Conditional sums & products
*Exponents & logarithms
*The trigonometric ratios
Most Frequently Used Mathematical
Functions
MEDIAN (Situated in the middle)
=MEDIAN(A1:A7)
Find the median of the values of cells A1 through A7.
For example, four is the median for 1, 2, 3, 4, 5, 6, 7.
MIN AND MAX
=MIN/MAX(X:X) Min and Max represent the minimum or maximum amount
in the cells.
For example, if you wanted to get the minimum value between cells A1 and
A30, you would put =MIN(A1:A30) or if you wanted to get the Maximum value
=MAX(A1:A30).
SYNTAX OF A FUNCTION
Most of the functions found in Excel require some input or information to calculate
correctly.
SYNTAX – Refers to the layout and order of the function and its arguments.
Also refers to the placement of round brackets or parentheses surrounding the
arguments and the use of the comma as a separator between the individual
arguments.
A function's arguments refer to all the data or information required by a function.
These arguments must be entered in the correct order. Most arguments are required,
but some are optional
When using the AVERAGE or SUM functions, you need to give it a range of numbers to
average or sum. Any input you give to a function is called an argument.
FUNCTION
ARGUMENT(S)
Arguments are the values that functions use to perform calculations
Types of Arguments in a Function
A. No arguments : such as RAND(), TODAY(), and NOW()
B. One argument: MAX(A1:A6), If you have defined a name for A1:A20 (such as
Sales), you can use the name in place of the reference: =SUM(Sales)
C. A fixed number of arguments: use multiple arguments in a function that uses a
comma in between =AVERAGE(A1:A6,B1:B6) & =SUM(A1:A6,B1:B6), =LEFT(A1,1)
D. Optional arguments: denoted with square brackets, i.e. used in VLOOKUP
(covered later on).
FUNCTION
ARGUMENT/S
There are two ways in which you can insert arguments in Excel.
• Typing the function directly in a cell
• Using the Excel function Argument dialogue box.
Numeric data (=SUM(5,10))
Text-string data (=UPPER(“siam”))
Boolean values (=OR(1+1=2))
Other functions (=DATE(YEAR(A2) + B2, MONTH(A2), DAY(A2)))
Round Functions
Excel round functions alter the actual value in a cell.
ROUND is the major rounding function in Excel that rounds a numeric
value to a specified number of digits.
Syntax: ROUND(number, num_digits)
Number - any real number you want to round. This can be a number,
reference to a cell containing the number or a formula which results
in a number..
Num_digits - the number of digits to round the number to, argument
can be a negative or positive integer(whole number)
Round Function Examples
If num_digits is greater than 0, the number is rounded to the specified number of decimal
places.
For example =ROUND(15.55, 1) rounds 15.55 to 15.6.
If num_digits is less than 0, all decimal places are removed and the number is rounded to the
left of the decimal point (to the nearest ten, hundred, thousand, etc.) Rounds the number of
places to the left of the decimal point
For example =ROUND(15.55, -1) rounds 15.55 to the nearest 10 and returns 20 as the
result.
If num_digits equals 0, the number is rounded to the nearest integer (no decimal places).
For example =ROUND(15.55, 0) rounds 15.55 to 16.
The number is rounded to the nearest whole number.
Round General Rules
Does follow the general math rules for rounding
Where the number to the right of the rounding
digit determines whether the number is rounded
upwards or downwards
Rounding digit is the last significant digit retained
once the number is rounded
Round General Rules
Changes do depend on whether the digit that follows it is
greater or less than 5:
If the digit to the right of the rounding digit is 0, 1, 2, 3, or 4,
the rounding digit is not changed, and the number is said to
be rounded down.
If the rounding digit is followed by 5, 6, 7, 8, or 9, the
rounding digit is increased by one, and the number is
rounded up.
ROUND Formula
• How ROUND function is written and its result.
PRODUCT Function
Returns the product (multiplication) of a supplied set of
numerical values.
The syntax of the function is:
PRODUCT( number1, [number2], ... )
Where the number arguments are a set of numbers (or arrays
of numbers) that you want to calculate the product of.
Each argument can consist of an array of values or a range of
cells, each of which can contain many values.
PRODUCT Function
Date & Time Values
• Date & Time values are stored as decimals, comprised
of:
• an integer (representing the date)
• A fraction between 0 and 1 (representing the time)
• The cells should be made to show the correct result by
formatting into a 'General', 'Date', 'Time', or 'Date &
Time' format, depending on the required result type
Adding and Subtracting Dates
and Times
Since Excel stores dates & times as numbers, you can add, subtract and
compare dates and times in Excel in the same way that you would add or
subtract any other numbers.
Example - Calculate the Number of Days Between Two Given Dates
Cell B1 of the spreadsheet on the right uses the formula =A2-A1 to calculate
the number of days between the dates 20/08/2010 & 31/08/2010 (stored in
cells A1 and A2).
This gives the result 11.
Calculate the Difference Between Two
Times
Cell B1 of the spreadsheet on the right uses the formula =A2-A1 to calculate the
number of hours and minutes between the times 13:00 & 17:15 (stored in cells A1 and
A2).
Note that: To display this result, cell B1 should be formatted to have the time format
"hh: mm"
This gives the result 04:15
Calculate the Difference Between Two
Dates and Times
Cell B1 of the spreadsheet on the right uses the formula =A2-A1 to calculate the
number of hours and minutes between the two dates & times stored in cells A1
and A2.
This gives the result 16:00.
Note that: In order to display this result, cell B1 should be formatted to have the
time format "hh:mm".
Date Function
When supplied with integers representing a year,
month and day, the Excel date function returns an Excel
date.
Note that the results in column E of the above spreadsheet are formatted with
the Time format hh:mm:ss.
Also note that, in cell E4, the Excel Time function successfully converts the
supplied value, 73 seconds, into the time of 1 minute and 13 seconds.
Time Function Errors
Particularly useful when you need to cross reference between different data
sets.
Basically, VLOOKUP lets you search for specific information in your spreadsheet.
For example, if you have a list of products with prices, you could search for the price of a
specific item.
VLOOKUP SYNTAX – 1
The syntax
=VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)
The first three parameters are REQUIRED, the last one is optional.
VLOOKUP SYNTAX –
2
1. lookup_value - the name of the item you're searching for.
a. can be either a value (number, date or text) or a cell reference (reference to
a cell containing a lookup value), or the value returned by some other Excel
function.
2. table_array - cell range that contains the data (two or more columns).
a. always searches for the lookup value in the first column of table_array.
b. The table_array may contain various values such as text, dates, numbers, or
logical values.
c. Values are case-insensitive, meaning that uppercase and lowercase text are
treated as identical.
VLOOKUP EXAMPLES – 1
Look up for number: =VLOOKUP(40, A2:B15, 2) - the formula will search for the
number 40.
Look up for text: =VLOOKUP("apples", A2:B15, 2) - the formula will search for
the text "apples".
Look up for value in another cell: =VLOOKUP(C2, A2:B15, 2) - the formula will
search for the value in cell C2.
VLOOKUP FUNCTION EXAMPLES
=VLOOKUP(40, A2:B15,2)
The function searches for "40" in cells A2 to A15 because A is the first
column of the table_array A2:B15
It always searches for the lookup value in the left-most column of the
lookup range (table_array).
If the 3rd parameter (col_index_num) is less than 1, the function will
return the #VALUE! error.
In cases when the argument is greater than the number of columns in
table_array, the function will return the #REF! error.
VLOOKUP FUNCTION – TIP
Use absolute cell references in the table_array argument of your
VLOOKUP formulas to have the correct lookup range when copying
the formulas. In this case, the lookup range will remain constant when
you copy the formula to other cells.
Consider using named ranges or Excel tables as an alternative.
When searching with approximate match (range_lookup set to TRUE
or omitted), always have the data in the first column in your lookup
range sorted in ascending order.
VLOOKUP FUNCTION - THINGS TO REMEMBER!
The importance of the final parameter. Supply TRUE or FALSE when appropriate.
When looking for exact matches, the fourth argument should always be FALSE; VLOOKUP
first searches vertically down the first column
VLOOKUP has two modes of operation: exact match and approximate match.
In most cases, you'll probably want to use VLOOKUP in exact match mode
Exact and approximate matching in VLOOKUP is controlled by the 4th argument, called
"range lookup"
VLOOKUP FUNCTION
VLOOKUP has two modes of operations: exact match and approximate match.
In most cases, you'll probably want to use VLOOKUP in exact match mode
• If, however, VLOOKUP encounters a value greater than the lookup value, it will return a
value from the previous row.
• This is a dangerous default because many people unwittingly leave VLOOKUP in its default
mode, which can cause an incorrect result when the table is not sorted.
• To avoid this problem, make sure to use FALSE or zero as the 4th argument when you want
an exact match.
Any Questions
Next week’s lecture covers Advanced Functions