Create array with calculated values
=MAKEARRAY(rows, columns, function)
| Parameter | Description |
|---|---|
rows |
The number of rows to create. |
columns |
The number of columns to create. |
function |
The custom LAMBDA calculation to apply. |
The MAKEARRAY function returns an array with specified rows and columns, based on a custom LAMBDA calculation. MAKEARRAY can be used to create arrays
=MAKEARRAY(rows,columns,function)
The MAKEARRAY uses the LAMBDA function to apply the function used to calculate array values. The structure of the LAMBDA used by MAKEARRAY is:
LAMBDA(r,c,calculation)
In the formula below, MAKEARRAY is used to create an array with 2 rows and 3 columns, populated with the result multiplying rows by columns:
=MAKEARRAY(2,3,LAMBDA(r,c,r*c)) // returns {1,2,3;2,4,6}
The result is a 2 x 3 array with six values {1,2,3;2,4,6}. The calculation can be a hardcoded value as well. Below are examples of the same formula, w
=MAKEARRAY(2,3,LAMBDA(r,c,0)) // returns {0,0,0;0,0,0}
=MAKEARRAY(2,3,LAMBDA(r,c,"x")) // returns {"x","x","x";"x","x","x"}
MAKEARRAY can be used to generate random values. In the formula below. The CHAR function is used with the RANDBETWEEN function to generate random uppe
=MAKEARRAY(2,3,LAMBDA(r,c,CHAR(RANDBETWEEN(65,90))))