Going Stellar

Home/Google Sheets reference

Google Sheets function · Math

SUM in Google Sheets: syntax and examples

SUM adds every number in the values and ranges you give it. Text and blank cells inside a range are skipped, so one stray word does not break the total. Text typed directly as an argument is different and can return an error.

Syntax

SUM(value1, [value2, ...])

Arguments

ArgumentTypeRequiredWhat it does
value1anyyesThe first number, cell or range to add.
value2anynoMore numbers, cells or ranges. You can repeat this argument.

Examples

The examples use this table, starting in A1:

ProductQ1Q2Q3
Pen10205
Pad4n/a8
Ink27
Tape639
=SUM(B2:B5)

Result: 22

A column total.

Run in a Google Sheet (English US locale) on .

=SUM(B2:D2, 100)

Result: 135

A row range plus a fixed number in the same call.

Run in a Google Sheet (English US locale) on .

=SUM(C2:C5)

Result: 30

The text "n/a" inside the range is skipped.

Run in a Google Sheet (English US locale) on .

=SUM(B2:D5)

Result: 74

A two-dimensional block. Blank cells count as nothing.

Run in a Google Sheet (English US locale) on .

=ROUND(SUM(B2:B5)/SUM(B2:D5), 3)

Result: 0.297

Share of Q1 in the whole block, rounded to three decimals.

Run in a Google Sheet (English US locale) on .

=SUM(ARRAYFORMULA(IF(B2:B5>3, B2:B5, 0)))

Result: 20

Sum only the values above 3. ARRAYFORMULA lets IF test every cell.

Run in a Google Sheet (English US locale) on .

Common errors

  • Text inside a range is skipped silently. A column of numbers stored as text sums to 0, so check the result against COUNT.
  • Text typed directly as an argument returns #VALUE!: =SUM(B2:B5, "n/a") fails, while the same word inside a range would be ignored.
  • A number written in quotes is converted: =SUM("5", 1) returns 6. The same string inside a cell range is skipped, which makes the two cases easy to mix up.

Compared with Excel

Same syntax and the same handling of text in ranges as Excel SUM.

Questions and answers

Why does SUM return 0 on a column that clearly has numbers?

The cells hold text, not numbers, so SUM skips them. Convert them with VALUE, or multiply the range by 1 inside ARRAYFORMULA.

Sources

  1. SUM (Docs Editors Help)

Markdown version · All functions