INDEX
Returns the value or reference at a 1-based row and column within an array or range.
INDEX can operate on both references and array literals. When the first argument is
a reference, this implementation resolves a referenced cell and materializes its value in
value context.
The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.
Syntax
=INDEX(array, row_num, [column_num])
Arguments
| Argument | Type | Required | Default |
|---|---|---|---|
array | any (range) | Required | — |
row_num | number | Required | — |
column_num | number | Optional | — |
Return type
Can return a reference when evaluated in a reference context.
Differences from Excel
Formualizer does not accept the area_num argument from Excel’s reference form.
Remarks
- Indexing is 1-based for both
row_numandcolumn_num. - If
column_numis omitted for a single-row or single-column input,row_numselects the position along that 1D vector. - For rectangular 2D inputs, omitted
column_numdefaults to the first column. - A
row_numorcolumn_numof0selects the entire column or row respectively (both0selects the whole range), matching Excel. - Index arguments coerce like Excel: a blank is
0,TRUEis1and numeric text is parsed; other text returns#VALUE!.
Error cases
- Negative or out-of-bounds indexes return
#REF!. Excel returns#VALUE!for a negative index; this implementation does not match that yet.
Examples
Retrieve the value in row two of the first column.
Formula =INDEX({10,20;30,40},2,1)
Expected result 30
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Omit the column on a single-column array.
Formula =INDEX({10;20;30},2)
Expected result 20
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Retrieve the first row and first column.
Formula =INDEX({10,20;30,40},1,1)
Expected result 10
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
A row outside the input array has no value.
Formula =INDEX({10,20;30,40},3,1)
Expected result #REF!
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Pick a value from a 2D table
Formula =INDEX(A1:B3,3,2)
| A | B | |
|---|---|---|
| 1 | "Item" | "Price" |
| 2 | "Pen" | 2.5 |
| 3 | "Book" | 8 |
Expected result 8
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Index into a 1D vector
Formula =INDEX(A1:A3,2)
| A | |
|---|---|
| 1 | "Q1" |
| 2 | "Q2" |
| 3 | "Q3" |
Expected result Q2
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Related functions
FAQ
How does INDEX behave when column_num is omitted?
For single-row or single-column inputs, row_num selects the position along that vector; for 2D inputs, omitted column_num defaults to the first column.
Which errors indicate bad indexes?
Text that is not a number returns #VALUE! (a blank index is 0, TRUE is 1, numeric text is parsed). A 0 row_num/column_num selects an entire column/row (Excel behavior); negative or out-of-bounds indexes return #REF!.