# SELECT\_BYINDEX

The SELECT\_BYINDEX function returns an array of measure values by selecting columns based on their numerical positions, from the start index to the end index. It should be used in conjunction with an aggregate function such as SUM, AVERAGE, etc.

## Syntax

```javascript
SELECT_BYINDEX(measure,start_index,end_index)
```

## Arguments

measure - String. Specify the name of the measure to select values from.

start\_index - Number. The starting column index from which the data must be fetched (1-based indexing). Required. Index-based identifiers can also be used instead of numbers.

end\_column - Number. The index of the ending column until which data has to be retrieved. Required. Index-based identifiers can also be used instead of numbers.

## Return value

Array of data.

## Example

{% code overflow="wrap" %}

```javascript
SELECT_BYINDEX([Sales],1,3)

//Returns an array containing values from the first, second, and third columns of the 'Sales' measure

SUM(SELECT_BYINDEX([Sales],1,3))

//Calculates the sum of values from the first through third columns of the 'Sales' measure
```

{% endcode %}

In the following example, we used the SELECT\_BYINDEX function to forecast values using the current quarter's actuals and the next three quarters' actuals.&#x20;

Unlike the SELECT function, SELECT\_BYINDEX allows you to use identifiers in the start and end column indexes, allowing you to perform cross-year data analysis that the SELECT function does not allow.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FmWhDEvfXWApMHDAtH5B5%2Fimage.png?alt=media&#x26;token=a8169c74-997c-4eae-99d3-0dd88664353d" alt=""><figcaption><p>SELECT_BYINDEX</p></figcaption></figure>

{% hint style="info" %}
Users are recommended to use the SELECT\_BYINDEX function when working on reports containing time-series dimensions in columns.
{% endhint %}
