Skip to content

SUMSQ

Returns the sum of the squares of the numbers you give it. SUMSQ(3, 4) is 25. It is the building block for distances and error measures.

Syntax

=SUMSQ(, [number2], …)

Math and trigonometry

All versions of Excel.

Try it

Edit the formula in C2 or change the inputs. The sheet recalculates as you type.

C2
A
B
C
1
a
b
a² + b²
2
3
4
25
3

C2 =SUMSQ(A2,B2) returns 25

How SUMSQ works

SUMSQ squares each number and adds the results. =SUMSQ(3, 4) is 9 + 16 = 25, and =SUMSQ(B2:B6) squares and adds every number in the range. It saves writing a helper column of squares and a SUM under it.

Distance and Pythagoras

The straight-line distance between two points uses SUMSQ naturally: =SQRT(SUMSQ(3, 4)) is 5. With the x gap in one cell and the y gap in another, =SQRT(SUMSQ(G2-E2, H2-F2)) gives the distance without writing each square.

Measuring forecast error

Squaring errors makes every error positive and punishes large misses more than small ones. SUMSQ of a column of errors is the sum of squared errors. Divide by the count and take the root to get the root mean square error:

=SQRT(SUMSQ(B2:B6)/COUNT(B2:B6))

This is a standard accuracy measure for forecasts. A forecast that is wrong by 10 once scores worse than one that is wrong by 2 five times, which matches how most people judge a miss.

Squared deviations

With a calculation inside, SUMSQ gives the total of squared deviations from the mean: =SUMSQ(B2:B6-AVERAGE(B2:B6)). In Microsoft 365 this works as an ordinary formula. In older versions it needs Ctrl+Shift+Enter. DEVSQ does the same job in one function and is the cleaner choice.

What SUMSQ ignores

Within a range or a cell reference, text, TRUE/FALSE and empty cells are ignored. Values typed straight into the formula are used, so =SUMSQ("3", 4) is 25. Errors in a range pass through.

SUMSQ compared with other functions

  • SUM adds the numbers themselves.
  • SUMPRODUCT of a range with itself, =SUMPRODUCT(B2:B6, B2:B6), gives the same answer as SUMSQ.
  • POWER squares one number at a time.
  • SQRT takes the root, which is the usual next step.

Because negative numbers square to positive ones, SUMSQ(-3, 4) is also 25. The sign of an error is lost, which is deliberate when you only care about its size.

Arguments

number1
The first number, cell, range or array to square and add, such as B2:B9.
number2, …optional
More numbers, cells, ranges or arrays, up to 255 arguments in all.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Sum of two squares

C2 =SUMSQ(A2,B2)

Result: 25

3 squared is 9 and 4 squared is 16.

C2
A
B
C
1
a
b
a² + b²
2
3
4
25
3

C2 =SUMSQ(A2,B2) returns 25

Example 2

Sum of squares over a range

C2 =SUMSQ(A2:A4)

Result: 14

1 + 4 + 9.

C2
A
B
C
1
Value
Sum of squares
2
1
14
3
2
4
3
5
6

C2 =SUMSQ(A2:A4) returns 14

Example 3

Hypotenuse of a right triangle

C2 =SQRT(SUMSQ(A2,B2))

Result: 5

SUMSQ gives 25 and SQRT takes the root.

C2
A
B
C
D
1
Across
Up
Distance
2
3
4
5
3

C2 =SQRT(SUMSQ(A2,B2)) returns 5

Example 4

Squared deviations from the mean

C2 =SUMSQ(A2:A6-AVERAGE(A2:A6))

Result: 40

The mean is 6, and the deviations -4, -2, 0, 2 and 4 square to 16, 4, 0, 4 and 16. DEVSQ gives the same result.

C2
A
B
C
1
Value
Squared deviations
2
2
40
3
4
4
6
5
8
6
10
7
8

C2 =SUMSQ(A2:A6-AVERAGE(A2:A6)) returns 40

Example 5

Root mean square error

B7 =ROUND(SQRT(SUMSQ(A2:A5)/COUNT(A2:A5)),2)

Result: 3.16

The squared errors add to 40. Divided by 4 that is 10, and its square root is 3.16. The signs cancel out, so over- and under-forecasts both count.

B7
A
B
C
1
Error
2
2
3
-2
4
4
5
-4
6
7
RMSE
3.16

B7 =ROUND(SQRT(SUMSQ(A2:A5)/COUNT(A2:A5)),2) returns 3.16

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In B8, return the sum of the squares of the five forecast errors.

Answer in B8.

B8
A
B
C
1
Week
Forecast error
2
Wk 1
3
3
Wk 2
-4
4
Wk 3
5
5
Wk 4
-2
6
Wk 5
6
7
8
Sum of squared errors
9
RMSE (2 decimals)
10

Common mistakes

  • Squaring removes the sign, so SUMSQ cannot tell an over-forecast from an under-forecast. Keep a signed total next to it if direction matters.
  • Text and blanks inside a range are ignored, so a column with gaps squares only the numbers. Check COUNT matches the number of rows you expect.
  • A single large value dominates the total, because squares grow quickly. That is useful for error measures but distorts a plain sum of sizes.
  • Using a calculation inside SUMSQ, such as A2:A6-AVERAGE(A2:A6), needs Ctrl+Shift+Enter before Microsoft 365. DEVSQ avoids that for deviations.
  • SUMSQ gives the sum of squares, not a distance or an average. You usually need SQRT or a division afterwards.

Questions people ask

What does SUMSQ do in Excel?

It squares each number and adds the squares. SUMSQ(3, 4) is 25.

How do I calculate root mean square error?

Use `=SQRT(SUMSQ(errors)/COUNT(errors))`. It squares the errors, averages them and takes the root.

What is the difference between SUMSQ and SUMPRODUCT?

For one range they give the same answer: `SUMSQ(B2:B9)` equals `SUMPRODUCT(B2:B9, B2:B9)`. SUMSQ is shorter. SUMPRODUCT can multiply different ranges.

Does SUMSQ ignore text?

In a range or cell reference, yes: text, TRUE/FALSE and blanks are skipped. Numbers typed directly into the formula are used.

How do I calculate the distance between two points?

Use `=SQRT(SUMSQ(x2-x1, y2-y1))`. SUMSQ adds the squared gaps and SQRT takes the root.

Learn SUMSQ in a real sheet.

Tracks take you from the basics to modelling, one graded exercise at a time.