SUMXMY2 function
SUMXMY2 totals the squared differences between paired values, the core of a sum-of-squared-errors calculation. Both arrays must be the same size or you get #N/A.
Example
Read it as a sentence: subtract each Z1:Z4 value from its matching Y1:Y4 value, square each difference, and add them up, which gives 4.
Excel shows 4
Y
Z
1
1
2
2
2
3
3
3
4
4
4
5
Data
Syntax
SUMXMY2(array_x, array_y)
-
array_x(required) - The first array.
-
array_y(required) - The second array, same size.
Returns: The sum of the squared differences between paired values.
What Excel actually returns
Each formula below was run in desktop Excel. The result is exactly what the cell showed, errors included.
| Formula | Excel shows | Case |
|---|---|---|
=SUMXMY2({1,2},{3,4}) | 8 | Arrays |
=SUMXMY2(3,2) | 1 | Scalars |
=SUMXMY2({1,2},{3;4}) | 8 | Row vs column same count |
=SUMXMY2(Data!Y1:Y4,Data!Z1:Z4) | 4 | Two ranges |
=SUMXMY2(Data!AD1:AD3,Data!AB1:AB3) | 0 | Text in range skipped |
=SUMXMY2(Data!Y1:Y4,Data!Z1:Z3) | #N/A | Size mismatch |
=SUMXMY2(Data!D1:D3,Data!AB1:AB3) | #DIV/0! | Blank pair skipped |
=SUMXMY2(Data!C1:C4,Data!Y1:Y4) | #N/A | Error |
The Data sheet these formulas read
A cell that starts with = holds that formula.
C
D
Y
Z
AB
AD
1
1
1
2
1
1
2
2
2
3
2
x
3
=NA()
3
4
3
3
4
4
4
5
Data
Watch out for
- Arrays must be the same size or you get #N/A.
Where it works
- Excel
- SUMXMY2 is in every version of Excel from 2007 on.
- Google Sheets
- Same name, same behaviour for everyday use.
Part of Math and trig functions. Every result on this page was measured in desktop Excel, build 16.0.20527. Last updated .