MSBA-171 · Lesson 9 of 12 · 21 min
Common functions: SUM, AVERAGE, IF and text functions
▶ Video coming soon A video version of this lesson is on the way.
By the ninth Tuesday the bookings table held 430 rows, and Rosalind wanted a one-page summary: totals, averages, counts, a list of packages sold and a column flagging which deposits were overdue. Dagny turned it into a tour of every function on MO-210. The exam lists them under "calculate and transform datasets" and "format and modify text", and it expects you to know what each one does and how to write it, not to memorize obscure arguments.
How a function is written
A function is a built-in formula with a name and arguments in parentheses, separated by commas. =SUM(E2:E430) has one argument, a range; =IF(F2>5000,"Large","Standard") has three. Arguments in square brackets in Excel's help, such as [columns] in SEQUENCE, are optional. When you type a function name and its opening parenthesis, a ScreenTip shows the arguments with the current one in bold. Insert Function (the fx button beside the formula bar, or Shift+F3) opens a dialog that searches functions and then shows the Function Arguments dialog with a box for each argument and a live preview of the result. The Formulas tab groups functions in its Function Library: AutoSum, Recently Used, Financial, Logical, Text, Date & Time, Lookup & Reference, Math & Trig and More Functions.
SUM, AVERAGE, MIN and MAX
These four take numbers, ranges or both and return one value. They ignore text and empty cells in ranges.
=SUM(Bookings[Fee]) total of all fees
=AVERAGE(Bookings[Guests]) mean guest count
=MIN(Bookings[Fee]) smallest fee
=MAX(Bookings[Event date]) latest event date (dates are numbers)
=SUM(E2:E20,E25,500) ranges, single cells and constants can be mixedAutoSum (Home > Editing, or Formulas > AutoSum, or Alt+=) writes a SUM for the numbers above or to the left of the active cell; its arrow offers Average, Count Numbers, Max and Min. AutoSum guesses the range, so check the moving border before you press Enter: a heading that is a number, such as a year, can sneak into the guess.
COUNT, COUNTA and COUNTBLANK
The three count functions differ in what they count, and the exam tests the difference:
| Function | Counts | Example on the Bookings table |
|---|---|---|
| COUNT | Cells containing numbers (including dates) | COUNT of Guests: bookings with a guest number entered |
| COUNTA | Cells that are not empty, of any type | COUNTA of Client: total bookings |
| COUNTBLANK | Empty cells in a range | COUNTBLANK of Deposit paid: bookings with no deposit date |
Teo's summary showed 430 bookings by COUNTA of Client, 427 by COUNT of Guests, and 3 by COUNTBLANK of Guests, which explained the #DIV/0! errors in lesson 8. A cell containing a formula that returns empty text ("") counts as not empty for COUNTA but as blank for COUNTBLANK, which occasionally makes the totals look inconsistent.
IF: making decisions
IF(logical_test, value_if_true, value_if_false) returns one value when a condition is true and another when it is false. The test uses a comparison operator from lesson 8; text results go in quotation marks; numbers and formulas do not.
=IF([@Guests]>120,"Large","Standard")
=IF([@Guests]=0,"",[@Fee]/[@Guests])
=IF([@[Deposit paid]]="","Due","Paid")
=IF([@Fee]>=10000,[@Fee]*0.05,0)The second formula fixed Teo's #DIV/0! problem: if there are no guests, show nothing; otherwise divide. The third flagged unpaid deposits. Dagny extended it with a date test so that only deposits for events in the next 60 days showed as overdue, which needed nested IF functions, an IF inside another IF's arguments:
=IF([@[Deposit paid]]<>"","Paid",IF([@[Event date]]-TODAY()<=60,"Overdue","Due later"))Read nested IFs from the outside in: if a deposit date exists, Paid; otherwise, if the event is within 60 days, Overdue; otherwise, Due later. Nested IFs beyond two or three levels are hard to read; Excel has IFS and SWITCH for longer chains, which the Expert exam covers. For MO-210, a single IF, and possibly one nested IF, is the expected level.
Worked problem
Choosing the right comparison
Write a test that is TRUE for a booking that is not a wedding, using the Event type column.
Show solution
- The "not equal" operator is a less-than sign followed by a greater-than sign.
- Text values in comparisons need quotation marks.
- Comparisons in Excel are not case-sensitive, so "wedding" also matches Wedding.
Answer: Event type not equal to "Wedding", inside IF: =IF([@[Event type]]<>"Wedding","Other","Wedding").
Dynamic arrays: SORT and UNIQUE
Excel for Microsoft 365 has dynamic array functions that return many values from one formula. The result spills into the cells below and to the right, outlined by a thin blue border when you select it. Only the first cell holds the formula; the others show greyed formula text in the formula bar. If anything is in the way, the formula shows #SPILL! until you clear the cells.
UNIQUE(array, [by_col], [exactly_once]) returns the distinct values in a range. SORT(array, [sort_index], [sort_order], [by_col]) returns the range sorted, with sort_order 1 for ascending and -1 for descending. They combine naturally:
=UNIQUE(Bookings[Package]) each package once, in order of first appearance
=SORT(UNIQUE(Bookings[Package])) the same list in A to Z order
=SORT(Bookings[[Client]:[Fee]],4,-1) the Client-to-Fee columns sorted by the 4th column, largest first
=UNIQUE(Bookings[Client],,TRUE) clients who booked exactly onceOn the summary sheet, Teo put =SORT(UNIQUE(Bookings[Package])) in A5 and the list of five packages spilled into A5:A9. When Maple & Pine added a sixth package, the list grew to six without any edit. To refer to a whole spilled result from another formula, use the spill range operator, a hash sign after the first cell: =COUNTA(A5#) counted the packages, however many there were.
SEQUENCE and RANDBETWEEN, from lesson 4, belong here too: SEQUENCE spills a list of numbers and RANDBETWEEN returns a random whole number. Together with SORT and UNIQUE they are the four dynamic or generating functions on MO-210.
Taking text apart: LEFT, RIGHT, MID and LEN
Booking codes at Maple & Pine looked like GG-2026-014: a package code, the year and a number. The text functions pull such codes apart.
| Function | Returns | Example | Result |
|---|---|---|---|
| LEFT(text, [num_chars]) | Characters from the start | LEFT(A2,2) | GG |
| RIGHT(text, [num_chars]) | Characters from the end | RIGHT(A2,3) | 014 |
| MID(text, start_num, num_chars) | Characters from the middle | MID(A2,4,4) | 2026 |
| LEN(text) | The number of characters, including spaces | LEN(A2) | 11 |
Text functions return text, even when the result looks like a number. MID(A2,4,4) returns the text 2026; to use it as a number, wrap it in VALUE or multiply it by 1. That detail matters when you sort or add up the results.
Changing case: UPPER and LOWER
UPPER(text) returns text in capital letters and LOWER(text) in small letters. Imported client emails came in mixed case; =LOWER([@Email]) made them consistent for the mailing system. Package codes typed as gg or Gg became GG with UPPER. (PROPER, which capitalizes each word, is the third case function, not named on MO-210 but useful for names.)
Joining text: CONCAT and TEXTJOIN
CONCAT(text1, [text2], ...) joins its arguments into one string, like the ampersand operator but accepting ranges. TEXTJOIN(delimiter, ignore_empty, text1, ...) joins with a separator between each item and can skip empty cells, which CONCAT cannot.
=CONCAT([@First]," ",[@Last]) Bianca Okafor
=[@First]&" "&[@Last] the same, with the & operator
=TEXTJOIN(", ",TRUE,B2:B6) Alder and Moss, Northshore Rotary, ... skipping blanks
=TEXTJOIN(" - ",FALSE,"GG",2026,"014") GG - 2026 - 014
=CONCAT(UPPER(LEFT([@Client],3)),"-",[@ID]) a code built from other functionsCONCATENATE, the older version of CONCAT, still works for compatibility but does not accept ranges; use CONCAT on the exam when a task names it. Dagny used TEXTJOIN to produce a single cell listing every venue booked for a weekend, separated by commas, which Rosalind pasted into her Monday email.
Combining functions
Functions can be arguments to other functions, as several examples above show. Build them from the inside out and check each piece: write MID(A2,4,4) and confirm it returns 2026 before wrapping it in VALUE, then in IF. Evaluate Formula (Formulas > Formula Auditing) steps through a combined formula one calculation at a time.
| Goal | Formula idea |
|---|---|
| Flag codes that are the wrong length | IF(LEN(code) is not 11, "Check", "") |
| Average fee of large events only | Filter the table to large events and read the total row's Average (SUBTOTAL) |
| A sorted list of clients in capitals | SORT(UPPER(UNIQUE(client column))) |
| Year from a booking code, as a number | VALUE(MID(code,4,4)) |
Functions on the exam
MO-210 tasks typically say something like "In cell H3, use a function to count the number of bookings that do not have a deposit date" or "In the Code column, use a text function to return the first two characters of the Booking ID". The checker looks at the formula, so use the function the task describes: COUNTBLANK, not a SUM of IFs; LEFT, not MID with a start of 1, unless either is accepted. Where a task says "use a structured reference" or "use the named range", do so. And where it gives a cell for the result, put the formula exactly there.
The Function Arguments dialog in practice
When you are unsure of a function's arguments, the Function Arguments dialog is the safest way to build it on the exam. Type the equals sign and the function name, then press Ctrl+A (or select the fx button). The dialog shows one box per argument, a description of the argument you are in, the value of each argument as you fill it, and the result at the bottom. Teo built his first nested IF this way, filling the outer IF's value_if_false box with a second IF by choosing it from the Name Box drop-down at the left of the formula bar while the dialog was open.
Checking results with the status bar
Before writing a function, select the range and read the status bar: it shows Average, Count and Sum by default, and right-clicking the status bar adds Numerical Count, Minimum and Maximum. Here Count means non-empty cells, like COUNTA, and Numerical Count means numbers, like COUNT. If your formula and the status bar disagree, one of them is looking at a different range.
A summary sheet from the functions in this lesson
Here is the summary Teo built for Rosalind, with the function behind each figure:
| Summary figure | Function |
|---|---|
| Bookings this season | COUNTA on the Client column |
| Bookings with guest numbers | COUNT on the Guests column |
| Bookings missing a deposit date | COUNTBLANK on the Deposit paid column |
| Total fees | SUM on the Fee column |
| Average guests | AVERAGE on the Guests column |
| Smallest and largest event | MIN and MAX on the Guests column |
| Packages sold | SORT of UNIQUE on the Package column, spilled |
| Venues booked, as one line of text | TEXTJOIN with a comma delimiter on the spilled venue list |
Every figure used structured references to the Bookings table, so the summary stayed correct as bookings arrived. Rosalind printed it every Monday.
Text functions for cleaning data
Imported data often needs tidying. A few patterns cover most cases at the Associate level. To make email addresses consistent, LOWER them. To check that every booking code has the expected length, compare LEN with 11 inside IF. To build a short label from a client's name and an ID, CONCAT the first three letters in UPPER case with a hyphen and the number. To pull the year out of a code, use MID, then VALUE if you need a number. TRIM, which removes extra spaces, is not on MO-210 but is the function people reach for first when imported text refuses to match.
Errors from functions
Each function has typical errors. AVERAGE of a range with no numbers returns #DIV/0!. A text function given a number works, but treats it as text. IF with a missing quotation mark around a text result returns #NAME?, because Excel reads the word as a name. A dynamic array formula returns #SPILL! when its spill range is blocked, and it cannot spill inside a table at all, which is why Teo's SORT and UNIQUE formulas sit on the Summary sheet rather than in a table column.
Common mistakes
MistakeUsing COUNT to count names or other text.
InsteadCOUNT counts numbers only; use COUNTA for any non-empty cell.
MistakeLeaving out the quotation marks around text results in IF.
InsteadPut text in quotation marks; numbers and references need none.
MistakeTyping over cells that a dynamic array needs, causing #SPILL!.
InsteadClear the cells in the spill range.
MistakeTreating the result of MID or LEFT as a number.
InsteadText functions return text; convert with VALUE if you need a number.
MistakeUsing CONCAT when separators and blank-skipping are needed.
InsteadUse TEXTJOIN with a delimiter and TRUE for ignore_empty.
Summary and key terms
- SUM, AVERAGE, MIN and MAX aggregate numbers; AutoSum (Alt+=) writes them quickly.
- COUNT counts numbers, COUNTA non-empty cells, COUNTBLANK empty cells.
- IF returns one of two values based on a test; IFs can be nested.
- SORT, UNIQUE and SEQUENCE spill dynamic arrays; #SPILL! means cells are in the way.
- LEFT, RIGHT, MID, LEN, UPPER, LOWER, CONCAT and TEXTJOIN take apart, change and join text.
- Function
- A named, built-in calculation with arguments in parentheses.
- Argument
- A value or reference a function uses, separated from others by commas.
- Nested function
- A function used as an argument of another function.
- Dynamic array
- A formula result of several values that spills into neighbouring cells.
- Spill range operator
- A hash sign after a cell, referring to the whole spilled result that starts there.
- TEXTJOIN
- A function that joins text with a delimiter and can skip empty cells.
- COUNTBLANK
- A function that counts empty cells in a range.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Which function counts the cells in a range that contain anything at all?
Show answer
COUNTA.
Write a formula that shows "Large" when Guests is over 120, otherwise "Standard".
Show answer
=IF([@Guests]>120,"Large","Standard").
What does =LEN("Garden Gold") return?
Show answer
11.
Which function returns the distinct values in a column?
Show answer
UNIQUE.
How do you join first and last names with a space using CONCAT?
Show answer
=CONCAT(first," ",last), with the cell references in place of first and last.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.