# INDEX function

**INDEX**(array, index)

**INDEX**(array; index)

## array

The array from which an element should be retrieved.

## index

The position of the element to return, starting with 1.

## Returns

The array element at the given position.

Returns the array element at the given position. INDEX({ 10, 20, 30 }, 2)INDEX({ 10; 20; 30 }; 2) returns the second element, 20.

## INDEX, MATCH and XMATCH

INDEX is often used together with MATCH and XMATCH to look up values from another array. MATCH and XMATCH are used to find a value in an array and return its position, where the position is then given to INDEX, which returns the array element at that position. Consider this formula:

The formula above returns 2, because the sought value, 20, is found at the second position in the { 10, 20, 30 }{ 10; 20; 30 } array.

As such, this formula returns 2 if the value of *Field1* is equal to
1, 4 if it is equal to 2 and 8 if it is equal to 3:

This XLOOKUP formula is equivalent:

## INDEX and SIZE

The SIZE function returns the number of elements in an array. It can be used together with INDEX to return array elements from the end of the array.

This formula returns the second array element:

This formula returns the second to last array element from the Field1:Field3Field1:Field3 array:

The Field1:Field3Field1:Field3
range is a short-hand way of expressing an array containing *Field1*
and *Field3*, as well as any fields that appear between them, such as
*Field2*. If only *Field2* appears between the other two
fields, Field1:Field3Field1:Field3 and { Field1, Field2,
Field3 }{ Field1;
Field2; Field3 } are equivalent.

## Multiple results

Multiple elements can be retrieved at the same time using INDEX, by supplying an array as the second parameter. This formula returns the first and third elements as an array, { 10, 30 }{ 10; 30 }:

## Examples

Returns the second element, 20.

Returns the first and third elements as an array, { 10, 30 }{ 10; 30 }.

Returns the last element from the Field1:Field20Field1:Field20 range, using the SIZE function, which returns the number of elements in an array.

Returns 2 if the value of *Field1* is equal to 1, 4 if it is equal
to 2 and 8 if it is equal to 3.