Sub topic 12
Rounding Results and Nesting Functions
Prerequisites and the calculation model
Assume you can enter formulas, use cell ranges such as B2:B6, and understand that AVERAGE calculates the mean of numeric cells.
Google Sheets stores calculated values with more precision than it may display. For example, an average might be 9.7666666667, while the cell displays 9.77 because of its formatting. Rounding changes the value returned by a formula. This is different from changing only the display format.
A nested function is a function placed inside another function. The inner function runs first, and its result becomes an argument for the outer function.
Rounding an aggregate result
Use ROUND(value, places) to round a value to a specified number of decimal places.
=ROUND(AVERAGE(B2:B6), 2)Google Sheets first calculates AVERAGE(B2:B6). It then rounds that result to two decimal places.
For example, suppose the numeric values in B2:B6 are 12.4, 7.1, and 9.8, with the other cells blank or containing text:
| Formula | Result before rounding | Result after rounding |
|---|---|---|
| `=AVERAGE(B2:B6)` | 9.7666666667 | 9.7666666667 |
| `=ROUND(AVERAGE(B2:B6), 2)` | 9.7666666667 | 9.77 |
The second argument, 2, means “keep two digits after the decimal point.” Use 0 for a whole number, 1 for one decimal place, and so on.
=ROUND(AVERAGE(B2:B6), 0)
=ROUND(AVERAGE(B2:B6), 1)
=ROUND(AVERAGE(B2:B6), 2)Rounding an average is useful for reports, scores, prices, and measurements. Keep the unrounded value when later calculations need maximum precision. Round at the reporting stage unless your calculation rules require rounding earlier.
Combining nesting with error handling
AVERAGE returns #DIV/0! when its range contains no numbers. Nest AVERAGE inside IFERROR when you want a readable result instead.
=IFERROR(AVERAGE(B2:B6), "No data")You can nest both functions to return a rounded average when data exists and a message when it does not:
=IFERROR(ROUND(AVERAGE(B2:B6), 2), "No data")The calculation order is:
AVERAGE(B2:B6)finds the mean.ROUND(..., 2)rounds the mean to two decimal places.IFERROR(..., "No data")replaces an error with the textNo data.
This structure keeps the normal result concise without hiding unexpected errors in unrelated formulas.
Common mistakes
=ROUND(B2:B6, 2)does not calculate an average. It tries to round the range directly, so useROUND(AVERAGE(B2:B6), 2)when the goal is a rounded mean.=AVERAGE(ROUND(B2:B6, 2))has a different purpose. It rounds individual cells before averaging them, which can produce a slightly different result.- The second argument is the number of decimal places, not the number of significant digits.
- A range containing text or blanks may have no numeric values, causing
AVERAGEto return#DIV/0!.
Exercise
Write a formula that calculates the average of numeric values in A2:A20, rounds it to one decimal place, and displays "No scores" if the range has no numbers.
Show answer
=IFERROR(ROUND(AVERAGE(A2:A20), 1), "No scores")