Column selection

Summary

This video looks at how to select which columns to return in the output.

Tab in example file: Column selection

Functions for shaping outputs include HSTACK, VSTACK, CHOOSECOLS, CHOOSEROWS, INDEX, CHOOSE, TAKE, DROP.

In this lesson we look at HSTACK and VSTACK and CHOOSECOLS and CHOOSEROWS in more detail.

HSTACK / VSTACK – Combine arrays or ranges horizontally (HSTACK) or vertically (VSTACK) into a single array, where each subsequent array or range is appended to the right or bottom.

The Syntax of HSTACK and VSTACK is:

=VSTACK(array1, [array2], [array3], …)
=HSTACK(array1, [array2], [array3], …)
  • array1 – Initial array or range.
  • [array2] – Array or range to append.
  • [array3] – Additional array or range to append.
  • … – On-going arrays to append.

CHOOSECOLS / CHOOSEROWS – Return the specified columns (CHOOSECOLS) or rows (CHOOSEROWS) from an array or range.

The Syntax of CHOOSECOLS and CHOOSEROWS is:

=CHOOSECOLS(array, col_num1, [col_num2], ...)
=CHOOSEROWS(array, row_num1, [row_num2], ...)
  • array – Array or range to return the columns/rows from.
  • col_num1 / row_num1 – First column/row number to return.
  • [col_num2] / [row_num1] – Second column/row number to return.
  • … – On-going row or column numbers.

The row_num and col_num arguments can be:

  • Negative values to select columns / rows from the end.
  • Arrays of column numbers.