Practice free

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.

Practice this in the app

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.

FormulaExcel showsCase
=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.

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 .