Formualizer Docs

CHOOSECOLS

Returns selected columns from an array or range.

CHOOSECOLS builds a new spilled array containing only the requested columns, in the order provided.

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

=CHOOSECOLS(array, col_num1, [col_num2], ...)

Arguments

ArgumentTypeRequiredDefault
arrayrange or any (range)Required—
col_num1numberRequired—
col_num2valueOptional—

Accepts a variable number of arguments. Minimum: 2.

Remarks

  • Column indexes are 1-based; negative indexes count from the end (-1 is last column).
  • Repeated indexes are allowed and duplicate columns in the output.
  • The result spills as an array unless it collapses to a single cell.

Error cases

  • Index 0 or out-of-bounds indexes return #VALUE!.

Examples

Select the middle column from a two-row array.

Formula =CHOOSECOLS({1,2,3;4,5,6},2)

Expected result {2; 5}

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

Use a negative index to select the last column, then append the first.

Formula =CHOOSECOLS({1,2,3;4,5,6},-1,1)

Expected result {3, 1; 6, 4}

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 one-cell input also has a first column.

Formula =CHOOSECOLS({7},1)

Expected result 7

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 column index beyond the array dimensions is invalid.

Formula =CHOOSECOLS({1,2,3;4,5,6},4)

Expected result #VALUE!

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

Select first and third columns

Formula =CHOOSECOLS(A1:C2,1,3)

Input cells
ABC
1"Name""Dept""Score"
2"Ana""Ops"91

Expected result {"Name", "Score"; "Ana", 91}

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

Select the last column with a negative index

Formula =CHOOSECOLS(A1:C1,-1)

Input cells
ABC
1102030

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

FAQ

How do negative column indexes work?

Negative indexes count from the right edge of the array, so -1 selects the last column, -2 the second-to-last, and so on.

What triggers #VALUE! in CHOOSECOLS?

Index 0 and any index whose absolute position falls outside the source width return #VALUE!.

Implementation

Engine source

On this page