SUMXMY2 Function

Excel Functions › Math & Trig

All versions Math & Trig

The Excel SUMXMY2 function returns the sum of squared differences — for each matched pair it computes (x − y)² and adds them, the core of squared-error and distance calculations.


Quick answer:
=SUMXMY2({2,3},{1,2}) = (2-1)^2 + (3-2)^2 = 2

Syntax

=SUMXMY2(array_x, array_y)
ArgumentDescription
array_xRequiredThe first array or range of values (the x values).
array_yRequiredThe second array or range, same size as array_x (the y values).

How to use it

SUMXMY2 subtracts each y from its paired x, squares the difference, and adds the results — it totals (x − y)² over both arrays.

=SUMXMY2({2,3},{1,2}) // 1 + 1 = 2
=SUMXMY2({5,7},{1,2}) // 16 + 25 = 41

This is the sum of squared errors (SSE) you see in regression, and the un-rooted form of Euclidean distance. The name reads as X Minus Y, squared.

Try it: interactive demo

Live demo

Pick a SUMXMY2 example to see the formula and its result.

Result:

Practice workbook

📊
Download the free SUMXMY2 practice workbook
Every example on this page, ready to open in Excel — plus practice challenges with answers on a separate tab. No sign-up required.

Frequently asked questions

What does SUMXMY2 compute?
The sum of squared differences: for each pair it finds (x − y)² and adds them. SUMXMY2({2,3},{1,2}) = 1² + 1² = 2.
How is SUMXMY2 different from SUMX2MY2?
SUMXMY2 sums (x − y)² — subtract first, then square. SUMX2MY2 sums (x² − y²) — square first, then subtract. Order matters and the results differ.
What is SUMXMY2 used for?
It is the sum of squared errors in regression and the squared Euclidean distance between two vectors. Take its SQRT to get the straight-line distance.
Do the arrays need to match in size?
Yes. If the two arrays differ in length, SUMXMY2 returns a #N/A error.

Master functions like this in one day

This page covers one function. Our Excel Formulas and Functions class covers the 30 that matter most — live, hands-on, taught by professionals in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related functions: SUMX2MY2 · SUMX2PY2 · SUMSQ · SUMPRODUCT · SUM