SUMXMY2 function
Adds the squared differences between matching values in two arrays, the basis of RMSE and least squares.
Available in All versions of Excel, Excel for the web, Excel for Mac
In every Excel versionWorks in Google Sheets
Syntax
SUMXMY2(array_x, array_y)| Argument | What it means | |
|---|---|---|
array_x | Required | The first range, e.g. forecasts. |
array_y | Required | The second range, e.g. actual results. Same number of values. |
Returns: Σ(x − y)² over all pairs.
How SUMXMY2 works
SUMXMY2 ("sum of x minus y, squared") is the most practical of the three pair-of-squares functions. For each row it takes the difference between two values, squares it and adds everything up. That is exactly the sum of squared errors (SSE) used to judge forecasts, compare measurements with targets, or fit a model by least squares.
Because the difference is squared, a miss of 8 counts four times as much as a miss of 4, so big errors dominate. Divide by the count and take the square root to get the root mean square error (RMSE) in the original units. Pairs containing text or blanks are skipped; unequal sizes return #N/A.
Examples
1Sum of squared forecast errors
| A | B | C | |
|---|---|---|---|
| 1 | Month | Forecast | Actual |
| 2 | Jan | 120 | 114 |
| 3 | Feb | 135 | 141 |
| 4 | Mar | 128 | 120 |
| 5 | Apr | 140 | 143 |
| 6 | May | 150 | 146 |
| 7 | 161 |
Result: 161
Differences 6, −6, 8, −3, 4 squared give 36 + 36 + 64 + 9 + 16 = 161.
2Root mean square error
| A | B | C | |
|---|---|---|---|
| 1 | Month | Forecast | Actual |
| 2 | Jan | 120 | 114 |
| 3 | Feb | 135 | 141 |
| 4 | Mar | 128 | 120 |
| 5 | Apr | 140 | 143 |
| 6 | May | 150 | 146 |
| 7 | |||
| 8 | 5.67 |
Result: 5.67
√(161 / 5) ≈ 5.67 units: on average the forecast is about 5.7 units away from reality (2 decimals).
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#N/A | Ranges of different sizes. | Use equally sized ranges. |
Tips
- Compare two forecasting methods by their SUMXMY2 against the same actuals: the lower one fits better.
- For average absolute error (MAE) use
=AVERAGE(ABS(B2:B6-C2:C6))in Microsoft 365.
Google Sheets
SUMXMY2 also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.
SUMXMY2 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.XMINY.2 |
| Finnish | EROTUSTEN.NELIÖSUMMA |
| French | SOMME.XMY2 |
| German | SUMMEXMY2 |
| Hungarian | SZUMXBŐLY2 |
| Italian | SOMMA.Q.DIFF |
| Norwegian (Bokmål) | SUMMERXMY2 |
| Polish | SUMA.XMY.2 |
| Portuguese (Brazil) | SOMAXMY2 |
| Portuguese (Portugal) | SOMAXMY2 |
| Russian | СУММКВРАЗН |
| Spanish | SUMAXMENOSY2 |
| Swedish | SUMMAXMY2 |
| Turkish | TOPXEY2 |