Contents
Index 🔎︎

# Array Functions

This category contains the array functions.

## What is an Array?

An array is a linked range of cells on a spreadsheet containing values. A square range of 3 rows and 3 columns is a 3 x 3 array:

| A | B | C | D | E
1 | 7 | 31 | 33
2 | 95 | 17 | 2
3 | 5 | 10 | 50
4

The smallest possible array is a 1 x 2 or 2 x 1 array with two adjacent cells.

## What is an array formula?

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.

Not only can an array formula process several values, but it can also return several values. The results of an array formula is also an array.

To multiply the values in the individual cells by 10 in the above array, you do not need to apply a formula to each individual cell or value. Instead you just need to use a single array formula. Select a range of 3 x 3 cells on another part of the spreadsheet, enter the formula =10*A1:C3 and confirm this entry using the key combination Command Ctrl + Shift + Enter. The result is a 3 x 3 array in which the individual values in the cell range (A1:C3) are multiplied by a factor of 10.

In addition to multiplication, you can also use other operators on the reference range (an array). With LibreOffice Calc, you can add (+), subtract (-), multiply (*), divide (/), use exponents (^), concatenation (&) and comparisons (=, <>, <, >, <=, >=). The operators can be used on each individual value in the cell range and return the result as an array if the array formula was entered.

Comparison operators in an array formula treat empty cells in the same way as in a normal formula, that is, either as zero or as an empty string. For example, if cells A1 and A2 are empty the array formulas {=A1:A2=""} and {=A1:A2=0} will both return a 1 column 2 row array of cells containing TRUE.

### When do you use array formulas?

Use array formulas if you have to repeat calculations using different values. If you decide to change the calculation method later, you only have to update the array formula. To add an array formula, select the entire array range and then make the required change to the array formula.

Array formulas are also a space saving option when several values must be calculated, since they are not very memory-intensive. In addition, arrays are an essential tool for carrying out complex calculations, because you can have several cell ranges included in your calculations. LibreOffice has different math functions for arrays, such as the MMULT function for multiplying two arrays or the SUMPRODUCT function for calculating the scalar products of two arrays.

## Using Array Formulas in LibreOffice Calc

### Implicit intersection of array formulas

You can also create a "normal" formula in which the reference range, such as parameters, indicate an array formula. This formula is also known as "implicit intersection" of array formula. The result is obtained from the intersection of the reference range and the rows or columns in which the formula is found. If there is no intersection or if the range at the intersection covers several rows or columns, a #VALUE! error message appears. The following example illustrates this concept:

In the table above, place the array formula in D1:

{=A1:A3 + 100}

Cells D1, D2, D3 have values 107, 195, 105 respectively.

Insert the formula below in E2, do not enter as array formula.

=A1:A3 + 100

Cells E1 and E3 are empty, Cell E2 has value 195. This is the implicit intersection of array formulas.

Insert formula below in E4, as in E2.

=A1:A3 + 100

Cell E4 display #VALUE!. Row 4 is out of the range A1:A3 of the formula.

### Creating Array Formulas

If you create an array formula using the Function Wizard, you must mark the Array check box each time 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 Shift + Command Ctrl + Enter instead of the Enter key. Only then does the formula become an array formula.

Array formulas appear in braces in LibreOffice Calc. You cannot create array formulas by manually entering the braces.

The cells in a results array are automatically protected against changes. However, you can edit, delete or copy the array formula by selecting the entire array cell range.

### Using Inline Array Constants in Formulas

Calc supports inline matrix/array constants in formulas. An inline array is surrounded by curly braces '{' and '}'. Elements can be each a number (including negatives), a logical constant (TRUE, FALSE), or a literal string. Non-constant expressions are not allowed. Arrays can be entered with one or more rows, and one or more columns. All rows must consist of the same number of elements, all columns must consist of the same number of elements.

The column separator (separating elements in one row) and the row separator are language and locale dependent. But in this help content, the ';' semicolon and '|' pipe symbol are used to indicate the column and row separators, respectively. For example, in the English locale, the ',' comma is used as the column separator, while the ';' semicolon is used as the row separator.

You can view and change the row and column separator in LibreOffice - Preferences Tools - Options - Calc - Formula - Separators.

Arrays can not be nested.

Examples:

={1;2;3}

An array with one row consisting of the three numbers 1, 2, and 3.

To enter this array constant, you select three cells in a row, then you type the formula ={1;2;3} using the curly braces and the semicolons, then press Command Ctrl + Shift + Enter.

={1;2;3|4;5;6}

An array with two rows and three values in each row.

={0;1;2|FALSE;TRUE;"two"}

A mixed data array.

=SIN({1;2;3})

Entered as a matrix formula, delivers the result of three SIN calculations with the arguments 1, 2, and 3.

### Editing Array Formulas

1. Select the cell range or array containing the array formula. To select the whole array, position the cell cursor inside the array range, then press Command Ctrl + /, where / is the division key on the numeric keypad.

2. Either press F2 or position the cursor in the input line. Both of these actions let you edit the formula.

3. After you have made changes, press Command Ctrl + Shift + Enter.

You can format the separate parts of an array. For example, you can change the font color. Select a cell range and then change the attribute you want.

### Deleting Array Formulae

1. Select the cell range or array containing the array formula. To select the whole array, position the cell cursor inside the array range, then press Command Ctrl + /, where / is the division key on the numeric keypad.

2. Press Delete to delete the array contents, including the array formula, or press Backspace and this brings up the Delete Contents dialog box. Select Formula or Delete All and click OK.

### Copying Array Formulas

1. Select the cell range or array containing the array formula.

2. Either press F2 or position the cursor in the input line.

3. Copy the formula into the input line by pressing Command Ctrl + C.

4. 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.

5. Paste the formula by pressing Command Ctrl + V in the selected space and confirm it by pressing Command Ctrl + Shift + Enter. The selected range now contains the array formula.

### Adjusting an Array Range

If you want to edit the output array, do the following:

1. Select the cell range or array containing the array formula.

2. 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 automatically be adjusted. You are only changing the range in which the result will appear.

By holding down the Command Ctrl key, you can create a copy of the array formula in the given range.

### Conditional Array Calculations

A conditional array calculation is an array or matrix formula that includes an IF() or CHOOSE() function. The condition argument in the formula is an area reference or a matrix result.

In the following example, the >0 test of the {=IF(A1:A3>0;"yes";"no")} formula is applied to each cell in the range A1:A3 and the result is copied to the corresponding cell.

| A | B (formula) | B (result)
1 | 1 | {=IF(A1:A3>0;"yes";"no")} | yes
2 | 0 | {=IF(A1:A3>0;"yes";"no")} | no
3 | 1 | {=IF(A1:A3>0;"yes";"no")} | yes

The following functions provide forced array handling: CORREL, COVAR, FORECAST, FTEST, INTERCEPT, MDETERM, MINVERSE, MMULT, MODE, PEARSON, PROB, RSQ, SLOPE, STEYX, SUMPRODUCT, SUMX2MY2, SUMX2PY2, SUMXMY2, TTEST. If you use area references as arguments when you call one of these functions, the functions behave as array functions. The following table provides an example of forced array handling:

| A | B (formula) | B (result) | C (forced array formula) | C (result)
1 | 1 | =A1:A2+1 | 2 | =SUMPRODUCT(A1:A2+1) | 5
2 | 2 | =A1:A2+1 | 3 | =SUMPRODUCT(A1:A2+1) | 5
3 |  | =A1:A2+1 | #VALUE! | =SUMPRODUCT(A1:A2+1) | 5

## FREQUENCY

Indicates the frequency distribution in a one-column-array. The function counts the number of values in the Data array that are within the values given by the Classes array.

#### Syntax

FREQUENCY(Data; Classes)

Data represents the reference to the values to be counted.

Classes represents the array of the limit values.

This function ignores any text or empty cell within a data range. If you suspect wrong results from this function, look for text in the data ranges. To highlight text contents in a data range, use the value highlighting feature.

You can find a general introduction to Array functions at the top of this page.

#### Example

In the following table, column A lists unsorted measurement values. Column B contains the upper limit you entered for the classes into which you want to divide the data in column A. According to the limit entered in B1, the FREQUENCY function returns the number of measured values less than or equal to 5. As the limit in B2 is 10, the FREQUENCY function returns the second result as the number of measured values that are greater than 5 and less than or equal to 10. The text you entered in B6, ">25", is only for reference purposes.

| A | B | C
1 | 12 | 5 | 1
2 | 8 | 10 | 3
3 | 24 | 15 | 2
4 | 11 | 20 | 3
5 | 5 | 25 | 1
6 | 20 | >25 | 1
7 | 16 |  |
8 | 9 |  |
9 | 7 |  |
10 | 16 |  |
11 | 33 |  |

Select a single column range in which to enter the frequency according to the class limits. You must select one field more than the class ceiling. In this example, select the range C1:C6. Call up the FREQUENCY function in the Function Wizard. Select the Data range in (A1:A11), and then the Classes range in which you entered the class limits (B1:B6). Select the Array check box and click OK. You will see the frequency count in the range C1:C6.

More explanations on top of this page.

## GROWTH

Calculates the points of an exponential trend in an array.

#### Syntax

GROWTH(DataY [; [ DataX ] [; [ NewDataX ] [; FunctionType ] ] ])

DataY represents the Y Data array.

DataX (optional) represents the X Data array.

NewDataX (optional) represents the X data array, in which the values are recalculated.

FunctionType (optional). If FunctionType = 0, functions in the form y = m^x will be calculated. Otherwise, y = b*m^x functions will be calculated.

In the LibreOffice Calc functions, parameters marked as "optional" can be left out only when no parameter follows. For example, in a function with four parameters, where the last two parameters are marked as "optional", you can leave out parameter 4 or parameters 3 and 4, but you cannot leave out parameter 3 alone.

More explanations on top of this page.

#### Example

This function returns an array and is handled in the same way as the other array functions. Select a range where you want the answers to appear and select the function. Select DataY. Enter any other parameters, mark Array and click OK.

## LINEST

Returns a table of statistics for a straight line that best fits a data set.

#### Syntax

LINEST(data_Y [; data_X [; linearType [; stats]]])

data_Y is a single row or column range specifying the y coordinates in a set of data points.

data_X is a corresponding single row or column range specifying the x coordinates. If data_X is omitted it defaults to 1, 2, 3, ..., n. If there is more than one set of variables data_X may be a range with corresponding multiple rows or columns.

LINEST finds a straight line y = a + bx that best fits the data, using linear regression (the "least squares" method). With more than one set of variables the straight line is of the form y = a + b1x1 + b2x2 ... + bnxn.

If linearType is FALSE the straight line found is forced to pass through the origin (the constant a is zero; y = bx). If omitted, linearType defaults to TRUE (the line is not forced through the origin).

If stats is omitted or FALSE only the top line of the statistics table is returned. If TRUE the entire table is returned.

LINEST returns a table (array) of statistics as below and must be entered as an array formula (for example by using Command Ctrl + Shift + Return rather than just Return).

In the LibreOffice Calc functions, parameters marked as "optional" can be left out only when no parameter follows. For example, in a function with four parameters, where the last two parameters are marked as "optional", you can leave out parameter 4 or parameters 3 and 4, but you cannot leave out parameter 3 alone.

More explanations on top of this page.

#### Example

This function returns an array and is handled in the same way as the other array functions. Select a range for the answers and then the function. Select data_Y. If you want, you can enter other parameters. Select Array and click OK.

The results returned by the system (if stats = 0), will at least show the slope of the regression line and its intersection with the Y axis. If stats does not equal 0, other results are to be displayed.

### Other LINEST Results:

Examine the following examples:

| A | B | C | D | E | F | G
1 | x1 | x2 | y |  | LINEST value |  |
2 | 4 | 7 | 100 |  | 4,17 | -3,48 | 82,33
3 | 5 | 9 | 105 |  | 5,46 | 10,96 | 9,35
4 | 6 | 11 | 104 |  | 0,87 | 5,06 | #NA
5 | 7 | 12 | 108 |  | 13,21 | 4 | #NA
6 | 8 | 15 | 111 |  | 675,45 | 102,26 | #NA
7 | 9 | 17 | 120 |  |  |  |
8 | 10 | 19 | 133 |  |  |  |

Column A contains several X1 values, column B several X2 values and column C the Y values. You have already entered these values in your spreadsheet. You have now set up E2:G6 in the spreadsheet and activated the Function Wizard. For the LINEST function to work, you must have marked the Array check box in the Function Wizard. Next, select the following values in the spreadsheet (or enter them using the keyboard):

data_Y is C2:C8

data_X is A2:B8

linearType and stats are both set to 1.

As soon as you click OK, LibreOffice Calc will fill the above example with the LINEST values as shown in the example.

The formula in the Formula bar corresponds to each cell of the LINEST array {=LINEST(C2:C8;A2:B8;1;1)}.

This represents the calculated LINEST values:

E2 and F2: Slope m of the regression line y=b+m*x for the x1 and x2 values. The values are given in reverse order; that is, the slope for x2 in E2 and the slope for x1 in F2.

G2: Intersection b with the y axis.

E3 and F3: The standard error of the slope value.

G3: The standard error of the intercept

E4: RSQ

F4: The standard error of the regression calculated for the Y value.

E5: The F value from the variance analysis.

F5: The degrees of freedom from the variance analysis.

E6: The sum of the squared deviation of the estimated Y values from their linear mean.

F6: The sum of the squared deviation of the estimated Y value from the given Y values.

More explanations on top of this page.

## LOGEST

This function calculates the adjustment of the entered data as an exponential regression curve (y=b*m^x).

#### Syntax

LOGEST(DataY [; DataX [; FunctionType [; Stats]]])

DataY represents the Y Data array.

DataX (optional) represents the X Data array.

FunctionType (optional). If Function_Type = 0, functions in the form y = m^x will be calculated. Otherwise, y = b*m^x functions will be calculated.

Stats (optional). If Stats=0, only the regression coefficient is calculated.

In the LibreOffice Calc functions, parameters marked as "optional" can be left out only when no parameter follows. For example, in a function with four parameters, where the last two parameters are marked as "optional", you can leave out parameter 4 or parameters 3 and 4, but you cannot leave out parameter 3 alone.

More explanations on top of this page.

#### Example

See LINEST. However, no square sum will be returned.

## MDETERM

Returns the array determinant of an array. This function returns a value in the current cell; it is not necessary to define a range for the results.

#### Syntax

MDETERM(Array)

Array represents a square array in which the determinants are defined.

You can find a general introduction to using Array functions on top of this page.

More explanations on top of this page.

## MINVERSE

Returns the inverse array.

#### Syntax

MINVERSE(Array)

Array represents a square array that is to be inverted.

More explanations on top of this page.

#### Example

Select a square range and select MINVERSE. Select the output array, select the Array field and click OK.

## MMULT

Calculates the array product of two arrays. The number of columns for array 1 must match the number of rows for array 2. The square array has an equal number of rows and columns.

#### Syntax

MMULT(Array 1; Array 2)

Array 1 represents the first array used in the array product.

Array 2 represents the second array with the same number of rows.

More explanations on top of this page.

#### Example

Select a square range. Choose the MMULT function. Select Array 1, then select Array 2. Using the Function Wizard, mark the Array check box. Click OK. The output array will appear in the first selected range.

## MUNIT

Returns the unitary square array of a certain size. The unitary array is a square array where the main diagonal elements equal 1 and all other array elements are equal to 0.

#### Syntax

MUNIT(Dimensions)

Dimensions refers to the size of the array unit.

You can find a general introduction to Array functions at the top of this page.

#### Example

Select a square range within the spreadsheet, for example, from A1 to E5.

Without deselecting the range, select the MUNIT function. Mark the Array check box. Enter the desired dimensions for the array unit, in this case 5, and click OK.

You can also enter the =MUNIT(5) formula in the last cell of the selected range (E5), and press Shift + Command + Enter Shift + Ctrl + Enter.

You now see a unit array with a range of A1:E5.

More explanations on top of this page.

## SUMPRODUCT

Multiplies corresponding elements in the given arrays, and returns the sum of those products.

#### Syntax

SUMPRODUCT(Array 1[; Array 2;][...;[Array 255]])

Array 1[; Array 2;][...;[Array 255]] represent arrays whose corresponding elements are to be multiplied.

At least one array must be part of the argument list. If only one array is given, all array elements are summed. If more than one array is given, they must all be the same size.

#### Example

| A | B | C | D
1 | 2 | 3 | 4 | 5
2 | 6 | 7 | 8 | 9
3 | 10 | 11 | 12 | 13

=SUMPRODUCT(A1:B3;C1:D3) returns 397.

Calculation: A1*C1 + B1*D1 + A2*C2 + B2*D2 + A3*C3 + B3*D3

You can use SUMPRODUCT to calculate the scalar product of two vectors.

SUMPRODUCT returns a single number, it is not necessary to enter the function as an array function.

More explanations on top of this page.

## SUMX2MY2

Returns the sum of the difference of squares of corresponding values in two arrays.

#### Syntax

SUMX2MY2(ArrayX; ArrayY)

ArrayX represents the first array whose elements are to be squared and added.

ArrayY represents the second array whose elements are to be squared and subtracted.

More explanations on top of this page.

## SUMX2PY2

Returns the sum of the sum of squares of corresponding values in two arrays.

#### Syntax

SUMX2PY2(ArrayX; ArrayY)

ArrayX represents the first array whose elements are to be squared and added.

ArrayY represents the second array, whose elements are to be squared and added.

More explanations on top of this page.

## SUMXMY2

Adds the squares of the variance between corresponding values in two arrays.

#### Syntax

SUMXMY2(ArrayX; ArrayY)

ArrayX represents the first array whose elements are to be subtracted and squared.

ArrayY represents the second array, whose elements are to be subtracted and squared.

More explanations on top of this page.

## TRANSPOSE

Transposes the rows and columns of an array.

#### Syntax

TRANSPOSE(Array)

Array represents the array in the spreadsheet that is to be transposed.

You can find a general introduction to using Array functions on top of this page.

#### Example

In the spreadsheet, select the range in which the transposed array can appear. If the original array has n rows and m columns, your selected range must have at least m rows and n columns. Then enter the formula directly, select the original array and press Shift + Command + Enter Shift + Ctrl + Enter. Or, if you are using the Function Wizard, mark the Array check box. The transposed array appears in the selected target range and is protected automatically against changes.

| A | B | C | D
1 | 2 | 3 | 4 | 5
2 | 6 | 7 | 8 | 9

The above table is 2 rows, 4 columns. In order to transpose it, you must select 4 rows, 2 columns. Assuming you want to transpose the above table to the range A7:B10 (4 rows, 2 columns) you must select the entire range and then enter the following:

TRANSPOSE(A1:D2)

Then make sure to enter it as matrix formula with Shift + Command + Enter Shift + Ctrl + Enter. The result will be as follows:

| A | B
7 | 2 | 6
8 | 3 | 7
9 | 4 | 8
10 | 5 | 9

## TREND

Returns values along a linear trend.

#### Syntax

TREND(DataY [; DataX [; NewDataX [; LinearType]]])

DataY represents the Y Data array.

DataX (optional) represents the X Data array.

NewDataX (optional) represents the array of the X data, which are used for recalculating values.

LinearType (optional). If LinearType = 0, then lines will be calculated through the zero point. Otherwise, offset lines will also be calculated. The default is LinearType <> 0.

In the LibreOffice Calc functions, parameters marked as "optional" can be left out only when no parameter follows. For example, in a function with four parameters, where the last two parameters are marked as "optional", you can leave out parameter 4 or parameters 3 and 4, but you cannot leave out parameter 3 alone.

More explanations on top of this page.

#### Example

Select a spreadsheet range in which the trend data will appear. Select the function. Enter the output data or select it with the mouse. Mark the Array field, click OK. The trend data calculated from the output data is displayed.

Related Topics

Functions by Category