SUMX2PY2 returns the sum of the squares of corresponding values in two arrays, calculated as Σ(x² + y²). It is a compact way to total squared values from paired data without building helper columns.
=SUMX2PY2(array_x, array_y)What does SUMX2PY2 do?
SUMX2PY2 is one of Excel's Math & Trigonometry functions. It takes two arrays of the same size, squares each value in both arrays, adds the two squares together for every row, and then sums all those results. In plain terms, it returns Σ(x² + y²) for your paired data.
This matters when you need a total of squared values but do not want to create extra helper columns. Instead of writing x² in one column and y² in another and then summing them, you point SUMX2PY2 at the two source ranges and get the answer in one cell. It is especially useful in engineering, statistics, and quality checks where squared values are common.
A typical situation is comparing two sets of measurements, such as actual versus target readings, and needing the combined squared total for a calculation. SUMX2PY2 keeps the worksheet clean and reduces the chance of a typo in a helper column.
When to use SUMX2PY2
- Totalling squared deviations for two paired measurement columns.
- Calculating combined squared values in engineering or physics worksheets.
- Quality control checks where both actual and target values must be squared.
- Statistical work that needs Σ(x² + y²) without helper columns.
- Budget or sales analysis comparing two numeric columns by squared totals.
SUMX2PY2 syntax
=SUMX2PY2(array_x, array_y)| Argument | Required? | What to enter |
|---|---|---|
array_x | Required | The first range or array of numbers. Each value is squared. Example: B2:B5. |
array_y | Required | The second range or array of numbers, the same size as array_x. Each value is squared and added to the matching x square. Example: C2:C5. |
What it returns: A single number: the sum of x² + y² for all corresponding pairs in the two arrays. If the arrays contain no numbers, it returns 0.
SUMX2PY2 examples
1 Example 1: Two short columns
This example uses two small columns of numbers to show the basic behaviour. The formula squares each value in B2:B4 and C2:C4, adds the matching squares, and totals them. For row 2, 3² + 4² = 9 + 16 = 25; row 3 gives 4 + 1 = 5; row 4 gives 25 + 36 = 61. The total is 25 + 5 + 61 = 91, which is what the formula returns.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Item | X | Y | |||
| 2 | A | 3 | 4 | 91 | ||
| 3 | B | 2 | 1 | |||
| 4 | C | 5 | 6 | |||
| 5 |
2 Example 2: Actual versus target readings
Here two measurement columns are compared. The formula squares each actual reading and each target reading, then adds the matching squares and sums the rows. Row 2 gives 100 + 121 = 221; row 3 gives 144 + 169 = 313; row 4 gives 196 + 225 = 421. The total is 221 + 313 + 421 = 955, which the formula returns.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Reading | Actual | Target | |||
| 2 | R1 | 10 | 11 | 955 | ||
| 3 | R2 | 12 | 13 | |||
| 4 | R3 | 14 | 15 | |||
| 5 |
3 Example 3: Sales versus returns by region
This business example pairs sales and returns figures by region. The formula squares each sales value and each returns value, adds the squares row by row, and totals them. Row 2 gives 1,000,000 + 10,000 = 1,010,000; row 3 gives 2,250,000 + 22,500 = 2,272,500; row 4 gives 1,600,000 + 14,400 = 1,614,400. The total is 4,896,900, which is what the formula returns.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Region | Sales | Returns | |||
| 2 | North | 1000 | 100 | 4736900 | ||
| 3 | South | 1500 | 150 | |||
| 4 | East | 1200 | 120 | |||
| 5 |
4 Example 4: Monthly budget versus actual spend
This example uses monthly budget and actual spend figures. The formula squares each budget value and each actual value, adds the matching squares, and sums the months. Row 2 gives 250,000 + 260,100 = 510,100; row 3 gives 300,000 + 313,600 = 613,600; row 4 gives 350,000 + 336,400 = 686,400. The total is 1,810,100, which the formula returns.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Month | Budget | Actual | |||
| 2 | Jan | 500 | 510 | 2010100 | ||
| 3 | Feb | 600 | 560 | |||
| 4 | Mar | 700 | 580 | |||
| 5 |
5 Example 5: Five rows of quality readings
This example uses five rows of quality readings to show a slightly larger table. The formula squares each value in B2:B6 and C2:C6, adds the matching squares, and totals them. The row results are 25, 61, 113, 181, and 265, which add up to 645. The formula returns 645.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Sample | X | Y | |||
| 2 | S1 | 3 | 4 | 645 | ||
| 3 | S2 | 5 | 6 | |||
| 4 | S3 | 7 | 8 | |||
| 5 | S4 | 9 | 10 | |||
| 6 | S5 | 11 | 12 | |||
| 7 |
Common SUMX2PY2 errors and how to fix them
| Error | Why it happens | How to fix it |
|---|---|---|
| #VALUE! | One or both arguments contain text that cannot be converted to a number. | Remove or correct text values in the ranges, or use numeric data only. |
| #N/A | The two arrays have different numbers of values. | Make sure array_x and array_y refer to ranges of the same size. |
| #NAME? | The function name is misspelled, such as SUMX2PY2 written incorrectly. | Check the spelling and use =SUMX2PY2( exactly. |
| Wrong total | The ranges are offset or include extra rows, so values are paired incorrectly. | Verify that both ranges start and end on the same rows. |
Tips for using SUMX2PY2
- Use ranges of identical size for array_x and array_y to avoid mismatched pairs.
- SUMX2PY2 ignores text and blank cells in the arrays, but text that looks numeric can still cause issues.
- If you need only the sum of x², use SUMSQ or SUMX2MY2 for x² − y².
- Name your ranges (for example, Actual and Target) to make formulas easier to read.
- Test with a small table first so you can confirm the result by hand.
Frequently asked questions
What does SUMX2PY2 actually calculate?
It calculates Σ(x² + y²): it squares each value in both arrays, adds the matching squares, and returns the total.
Can SUMX2PY2 handle text or blank cells?
Yes, it ignores text and blanks in the arrays, but text that cannot be interpreted as a number may cause a #VALUE! error.
What happens if the two arrays are different sizes?
Excel returns #N/A because the function needs one y value for every x value.
Is SUMX2PY2 the same as SUMSQ?
No. SUMSQ adds the squares of a single array. SUMX2PY2 adds x² + y² for two paired arrays.
Related functions
Every example on this page was recalculated by SheetSkill’s spreadsheet engine. SUMX2PY2 reference