Documentation/Calc Functions/SUMXMY2
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
Function name:
SUMXMY2
Category:
Array
Summary:
Calculates the sum of the squared differences between corresponding elements of two arrays.
A call to the SUMXMY2 function need not be entered as an array formula.
Syntax:
SUMXMY2(Array X; Array Y)
Returns:
Returns a real number that is the sum of the squared differences between corresponding elements of the two given arrays.
Arguments:
Array X is the first array to be used in the calculation. This argument can take the form of an explicit cell range (such as A1:C3), the name of a named range, the name of a database range, or an inline constant array.
Array Y is the second array to be used in the calculation. This argument can take the form of an explicit cell range (such as A1:C3), the name of a named range, the name of a database range, or an inline constant array. Array Y should be the same size as Array X.
- If either Array X or Array Y is not a single area reference, then SUMXMY2 reports an invalid argument error (Err:502). The tilde (~) reference concatenation operator cannot be used to join multiple areas in these arguments.
- If Array X and Array Y are of different sizes, then SUMXMY2 reports a #VALUE! error.
- If any cell within Array X or Array Y is non-numeric, then SUMXMY2 reports a #VALUE! error.
- For the purposes of its calculations, SUMXMY2 assumes a value of zero for any empty cell within Array X or Array Y.
Additional details:
Details specific to SUMXMY2 function
- SUMXMY2 performs the following calculation:
- [math]\displaystyle{ SUMXMY2(x, y)~=~\sum_{i=1}^{N}\left ( x_{i} - y_{i}\right )^2 }[/math]
- N is the number of elements in each of the arrays x and y.
- If you have trouble remembering the name of this function, it might help to consider the name SUMXMY2 to be shorthand for sum (x minus y)2.
General information about Calc's array functions
To avoid repetition within the subsequent text, only Windows/Linux key combinations are specified. The following table shows the mapping between these key combinations and their macOS equivalents.
Windows/Linux key combination | macOS equivalent | Comments |
---|---|---|
Ctrl + ⇧ Shift + ↵ Enter | ⌘ Cmd + ⇧ Shift + ↵ Enter | Create an array formula. |
Ctrl + / | ⌘ Cmd + / | Select all cells in an array formula range. "/" is the division key on the numeric keypad. |
Ctrl + C | ⌘ Cmd + C | Copy. |
Ctrl + V | ⌘ Cmd + V | Paste. |
- An array is a rectangular range of cells containing data. For example, a square range of three rows by three columns is a 3 x 3 array. The smallest possible array is a 1 x 2 or 2 x 1 array, with two adjacent cells.
- A formula in which the individual values in a cell range are evaluated is referred to as an array formula. The difference between an array formula and other formulas is that the array formula deals with several values simultaneously instead of just one.
- If you create an array formula using the Function Wizard, you must mark the Array check box so that the results are returned in an array. Otherwise, only the value in the upper-left cell of the array being calculated is returned.
- If you enter the array formula directly into the cell, you must use the key combination Ctrl + ⇧ Shift + ↵ Enter instead of just the ↵ Enter key. Only then does the formula become an array formula.
- An array formula is displayed inside curly brackets or braces ("{" and "}"). It is not possible to create an array formula by manually entering these braces.
- Some array functions take parameters that are forced to evaluate as an array formula, even when the formula is entered normally. These are MDETERM, MINVERSE, MMULT, SUMPRODUCT, SUMX2MY2, SUMX2PY2, and SUMXMY2.
- Calc supports constant inline arrays in formulas. An inline array is enclosed within curly brackets or braces ("{" and "}"). Individual elements can be numbers (including negatives), logical constants (TRUE, FALSE), or literal strings. Non-constant expressions are not allowed. Arrays can be entered with one or more rows, and one or more columns. All rows must comprise the same number of elements; similarly, all columns must comprise the same number of elements.
- Editing array formulas. Select the cell range containing the array formula. To select the whole range, position the cursor inside the range and press Ctrl + /. Then press F2 or position the cursor in the Input line, edit the formula as required, and use the key combination Ctrl + ⇧ Shift + ↵ Enter.
- Deleting array formulas. Select the cell range containing the array formula. To select the whole range, position the cursor inside the range and press Ctrl + /. Press Delete to delete the array contents, including the array formula. Alternatively, press ← Backspace to bring up the Delete Contents dialog box, select Formulas or Delete all, and click .
- Copying array formulas. Select the cell range containing the array formula. To select the whole range, position the cursor inside the range and press Ctrl + /. Then press F2 or position the cursor in the Input line. Copy the formula by pressing Ctrl + C. Select a range of cells where you want to insert the array formula and either press F2 or position the cursor in the Input line. Paste the formula by pressing Ctrl + V in the selected space and confirm it using the key combination Ctrl + ⇧ Shift + ↵ Enter. The selected range now contains the array formula.
- Adjusting an array range. Select the cell range containing the array formula. To select the whole range, position the cursor inside the range and press Ctrl + /. Below the selection, to the right, you will see a small icon with which you can zoom in or out on the range using your mouse. When you adjust the array range, the array formula will not be adjusted automatically - you are only changing the range in which the results will appear.
Examples:
Formula | Description | Returns |
---|---|---|
=SUMXMY2({1,2,3}; {4,5,6}) | Here the function calculates (1-4)2 + (2-5)2 + (3-6)2, or 27. | 27 |
=SUMXMY2(A1:B2; C3:D4) where cells A1, A2, B1, and B2 contain the values 6, 7, 8, and 9, while cells C3, C4, D3, and D4 contain the values 3, 4, 5, and 6. | Here the function calculates (6-3)2 + (7-4)2 + (8-5)2 + (9-6)2, or 36. | 36 |
=SUMXMY2(array_data1; array_data2) where array_data1 is a named range covering a 2 x 2 cell area containing the values {1.5, 3.5; 2.3, -4.7}, and array_data2 is a database range covering a 2 x 2 cell area containing the values {1, 2; 2, 1}. | Here the function calculates (1.5-1)2 + (3.5-2)2 + (2.3-2)2 + (-4.7-1)2, or 35.08. | 35.08 |
Related LibreOffice functions:
ODF standard:
Related (or similar) Excel functions:
SUMXMY2