Math & trig function

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)
ArgumentWhat it means
array_xRequiredThe first set of values (squared and added).
array_yRequiredThe 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

B6fx=SUMX2MY2(B2:B5, C2:C5)
ABC
1RoomNew side (m)Old side (m)
2Lobby65
3Office 143.5
4Office 243.5
5Kitchen32.5
621.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

B5fx=SUMX2MY2(B2:B4, C2:C4)
ABC
1ProductPrice 2026Price 2025
2A1210
3B89
4C54
536

Result: 36

(144 − 100) + (64 − 81) + (25 − 16) = 44 − 17 + 9 = 36. Negative pairs reduce the total.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 14 KB

Common errors and how to fix them

ErrorWhy it happensFix
#N/AThe 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.

LanguageFunction name
DutchSOM.X2MINY2
FinnishNELIÖSUMMIEN.EROTUS
FrenchSOMME.X2MY2
GermanSUMMEX2MY2
HungarianSZUMX2BŐLY2
ItalianSOMMA.DIFF.Q
Norwegian (Bokmål)SUMMERX2MY2
PolishSUMA.X2.M.Y2
Portuguese (Brazil)SOMAX2DY2
Portuguese (Portugal)SOMAX2DY2
RussianСУММРАЗНКВ
SpanishSUMAX2MENOSY2
SwedishSUMMAX2MY2
TurkishTOPX2EY2