Excel course · Lesson 5 of 34
Introduction to functions: reading syntax and nesting
Learn what a function is, how to read its syntax and arguments, use AutoSum and Insert Function, and nest one function inside another.
Excel has more than 500 built-in functions: ready-made formulas that do a job you would otherwise have to write out by hand. Adding 1,000 cells with + would be absurd; =SUM(B2:B1001) does it in one short instruction. In this lesson you will learn how any function is built, how to read its syntax from the tooltip, how to find the right function, and how to combine functions by nesting them.
The structure of a function
A function call has a name, followed by parentheses, and inside them the arguments, the inputs the function needs, separated by commas:
=ROUND(B7, 2)
=SUM(B2:B6)
=IF(C2>=50, "Pass", "Fail")
=TODAY()ROUNDis the name. Names are not case-sensitive; Excel convertsroundtoROUNDwhen you press Enter.B7and2are the arguments: the number to round and how many decimals to keep.- Arguments can be numbers, text in double quotes, cell references, ranges, logical values (
TRUE/FALSE) or other formulas. - Some functions need no arguments at all, like TODAY and NOW, but the empty parentheses are still required.
=ROUND(B7; 2). This course uses commas. If Excel rejects a formula from this site, swap the commas for semicolons. The separator follows the decimal separator chosen in Windows or macOS regional settings.Reading syntax
When you type =VLOOKUP( Excel shows a yellow tooltip with the syntax. Function pages on this site show the same thing. Here is how to read it:
ROUND(number, num_digits)
XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
SUM(number1, [number2], ...)- Arguments without brackets are required. Leave one out and Excel refuses the formula.
- Arguments in square brackets are optional and have a default value. In XLOOKUP, leaving out
match_modemeans exact match. ...means the argument can repeat. SUM accepts up to 255 numbers or ranges:=SUM(B2:B6, D2:D6, 100).- The bold argument in the tooltip is the one you are typing now. Click an argument name in the tooltip to select that part of the formula.
Six functions every user needs
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Student | Test 1 | Test 2 | Test 3 |
| 2 | Ana | 78 | 85 | 91 |
| 3 | Ben | 64 | 70 | 58 |
| 4 | Carla | 92 | 88 | 95 |
| 5 | David | 55 | absent | 73 |
| 6 | Elif | 81 | 79 | 84 |
| 7 | 74 |
Grades for five students. David missed Test 2, so C5 contains the text 'absent'.
Result: 74
| Formula | What it does | Result |
|---|---|---|
| =SUM(B2:B6) | Adds the numbers | 370 |
| =AVERAGE(B2:B6) | Arithmetic mean | 74 |
| =MIN(B2:B6) | Smallest value | 55 |
| =MAX(B2:B6) | Largest value | 92 |
| =COUNT(C2:C6) | Counts cells that contain numbers | 4 |
| =COUNTA(C2:C6) | Counts cells that are not empty | 5 |
| =AVERAGE(C2:C6) | Mean of Test 2, ignoring the text | 80.5 |
Look at the last three rows. COUNT only counts numbers, so David's 'absent' is skipped, while COUNTA counts every non-empty cell. AVERAGE also skips text, so the Test 2 average is calculated over four students. Whether that is fair is a business decision; if absent should count as zero, enter 0 instead of text.
Three ways to insert a function
1. AutoSum
- Click the cell under a column of numbers, for example
B7. - Choose Home › Editing › AutoSum (the Σ button) or press
Alt+=(Mac:Cmd+Shift+T). - Excel guesses the range and shows
=SUM(B2:B6)with a moving border. Check the range, adjust it by dragging if needed, and pressEnter. - Click the small arrow next to AutoSum to choose Average, Count Numbers, Max or Min instead.
Alt+=. Excel writes all the row and column totals in one go.2. Insert Function dialog
- Click the cell for the result and choose Formulas › Function Library › Insert Function, or click the fx button left of the formula bar (
Shift+F3). - Type a description such as
round a numberand click Go, or pick a category. - Select ROUND and click OK. The Function Arguments dialog opens with one box per argument and a short description of each.
- Fill in the boxes. The dialog previews the result at the bottom. Click OK.
The Function Arguments dialog is excellent for learning a new function, because it shows each argument's purpose and the current value of every input as you type.
3. Type it with Formula AutoComplete
Type = and the first letters, for example =AV. A list drops down with AVERAGE, AVERAGEA, AVERAGEIF and AVERAGEIFS. Use the arrow keys to choose and press Tab to accept; Excel adds the opening parenthesis. This is the fastest method once you know what you want.
Nesting functions
Any argument can itself be a function. Putting one function inside another is called nesting. Excel always calculates the innermost function first and passes its result outwards.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Student | Test 1 | Test 2 | Test 3 | Average |
| 2 | Ana | 78 | 85 | 91 | 84.7 |
| 3 | Ben | 64 | 70 | 58 | 64 |
| 4 | Carla | 92 | 88 | 95 | 91.7 |
AVERAGE calculates 84.666…, then ROUND keeps one decimal.
Result: 84.7
Read nested formulas from the inside out: first AVERAGE(B2:D2) = 84.666…, then ROUND(84.666…, 1) = 84.7. Another common pattern is =IF(COUNT(B2:D2)<3, "Incomplete", AVERAGE(B2:D2)): count the scores first, and only average them if all three exist.
=AVERAGE(B2:D2) in a helper cell, check it, then wrap it: =ROUND(AVERAGE(B2:D2),1). Excel colours matching parentheses as you type, which helps you see where each function ends.Function categories
Functions are grouped on the Formulas tab: Financial, Logical, Text, Date & Time, Lookup & Reference, Math & Trig, and More Functions (Statistical, Engineering, Information and others). You will meet the most useful ones in later lessons: IF in IF and logical formulas: AND, OR, NOT, IFS and SWITCH, XLOOKUP in Lookup guide: VLOOKUP vs INDEX/MATCH vs XLOOKUP, SUMIFS in Counting and summing with criteria: COUNTIFS, SUMIFS, SUMPRODUCT.
#NAME? (older versions prefix the name with _xlfn. in the formula bar). Every function page on this site lists its availability.Check yourself
1. In the syntax XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found]), what do the square brackets mean?
Square brackets mark optional arguments, which have a default value.
2. C2:C6 contains 85, 70, "absent", 88 and 79. What does =COUNT(C2:C6) return?
COUNT counts only cells containing numbers, so the text is ignored.
3. What does =ROUND(AVERAGE(10, 11, 11), 1) return?
The average is 10.666…, rounded to one decimal it is 10.7.
4. Which shortcut inserts AutoSum on Windows?
Alt+= inserts =SUM() with a suggested range. Shift+F3 opens Insert Function.
5. A colleague with Excel 2016 opens your file and sees #NAME? where you used XLOOKUP. Why?
XLOOKUP is available only in Microsoft 365 and Excel 2021 or later.