Sub topic 3
Adding values with SUM
This chapter assumes that you can enter data and formulas in Google Sheets and that you know cell addresses such as B2. You will use SUM to add numbers from one or more cells.
Cells and ranges
A cell is one location in a sheet. A range is a group of cells. The reference B2:B6 means every cell from B2 through B6 in column B.
| Reference | Meaning |
|---|---|
| `B2` | One cell |
| `B2:B6` | A vertical range from B2 through B6 |
| `B2:D6` | A rectangular range across columns B through D |
A range is useful when a list may change. Instead of typing every cell separately, pass the range to SUM.
The SUM function
SUM is a function that adds numeric values. A function call starts with an equals sign, followed by the function name and parentheses. Put the values or references to add inside the parentheses.
=SUM(B2:B6)If cells B2 through B6 contain 12, 8, 15, 10, and 5, the result is 50.
You can also add individual cells, but a range is usually easier to read:
=SUM(B2, B3, B4, B5, B6)Both formulas produce the same result for this list.
Combining ranges and values
The items inside a function call are called arguments. Separate multiple arguments with commas. An argument can be a range, a cell, or a literal number.
=SUM(B2:B6, D2:D6, 100)This formula adds all numbers in B2:B6, all numbers in D2:D6, and the additional value 100.
The following diagram shows how SUM combines its arguments.
Text, blanks, and zero
SUM adds numbers. It ignores empty cells and text in a referenced range. A zero is a number, so it is included, but adding zero does not change the total.
For example, if B2:B6 contains 12, an empty cell, 0, the text Pending, and 8, then this formula returns 20:
=SUM(B2:B6)A number stored as text, such as "12" entered with a leading apostrophe, may not behave like a numeric value. Check the cell's format and contents when a total seems too low.
Choosing a safe range
A total should usually be outside the range it adds. For example, if the values are in B2:B6, place the total in B7:
=SUM(B2:B6)Do not place =SUM(B:B) in column B. That whole-column reference includes the formula cell itself and creates a circular reference. A circular reference is a formula that depends on its own result.
A whole-column reference can be useful when the total is in another column:
=SUM(B:B)This includes new values added to column B automatically, but it also includes headers and any other numbers in that column.
Exercise
Cells B2:B5 contain 14, 6, a blank cell, and 10. Write a formula that adds the values and explain the result.
Show answer
Use =SUM(B2:B5). The result is 30 because SUM adds 14, 6, and 10, ignores the blank cell, and includes no other cells.