SUMX2MY2 function
Adds up the difference of squares (x² − y²) for matching values in two arrays.
Available in All versions of Excel, Excel for the web, Excel for Mac
In every Excel versionWorks in Google Sheets
Syntax
SUMX2MY2(array_x, array_y)| Argument | What it means | |
|---|---|---|
array_x | Required | The first set of values (squared and added). |
array_y | Required | The second set (squared and subtracted). Must have the same number of values as array_x. |
Returns: Σ(x² − y²) over all pairs.
How SUMX2MY2 works
The name reads as "sum of x squared minus y squared". For every pair of values in two equally sized ranges Excel squares both, subtracts the second square from the first and adds the results. It is the same as =SUMSQ(x) - SUMSQ(y) but in one step.
It is a niche function, mostly used in statistics formulas and in geometry where squares represent areas: for square rooms, tiles or plates it gives the total area gained or lost when side lengths change. Pairs where either value is text, logical or empty are skipped together. Ranges of unequal size give #N/A.
Examples
1Extra floor area after enlarging square rooms
| A | B | C | |
|---|---|---|---|
| 1 | Room | New side (m) | Old side (m) |
| 2 | Lobby | 6 | 5 |
| 3 | Office 1 | 4 | 3.5 |
| 4 | Office 2 | 4 | 3.5 |
| 5 | Kitchen | 3 | 2.5 |
| 6 | 21.25 |
Result: 21.25
(36 − 25) + (16 − 12.25) × 2 + (9 − 6.25) = 11 + 7.5 + 2.75 = 21.25 m² of extra floor (2 decimals).
2Difference of squared prices
| A | B | C | |
|---|---|---|---|
| 1 | Product | Price 2026 | Price 2025 |
| 2 | A | 12 | 10 |
| 3 | B | 8 | 9 |
| 4 | C | 5 | 4 |
| 5 | 36 |
Result: 36
(144 − 100) + (64 − 81) + (25 − 16) = 44 − 17 + 9 = 36. Negative pairs reduce the total.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#N/A | The two arrays have a different number of values. | Use ranges of the same size. |
Tips
- The result can be negative when y values are larger overall.
- Equivalent to
=SUMPRODUCT(x^2 - y^2)if you prefer one familiar function.
Google Sheets
SUMX2MY2 also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.
SUMX2MY2 in other languages
In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.
| Language | Function name |
|---|---|
| Dutch | SOM.X2MINY2 |
| Finnish | NELIÖSUMMIEN.EROTUS |
| French | SOMME.X2MY2 |
| German | SUMMEX2MY2 |
| Hungarian | SZUMX2BŐLY2 |
| Italian | SOMMA.DIFF.Q |
| Norwegian (Bokmål) | SUMMERX2MY2 |
| Polish | SUMA.X2.M.Y2 |
| Portuguese (Brazil) | SOMAX2DY2 |
| Portuguese (Portugal) | SOMAX2DY2 |
| Russian | СУММРАЗНКВ |
| Spanish | SUMAX2MENOSY2 |
| Swedish | SUMMAX2MY2 |
| Turkish | TOPX2EY2 |