New Array Shaping Excel Functions

Mynda Treacy

October 6, 2022

Microsoft recently released 11 new Excel functions for shaping arrays (data).

I already covered VSTACK and HSTACK which was super popular, and in this post I’m going to use some of the other new functions to do things that used to require ninja level function wrangling.

You can see the individual tutorials covered in the video or read about them at the links below.

Note: these functions are only available to Microsoft 365 users.

Download Cheat Sheet and Workbook

Array Shaping Functions Cheat Sheet

Enter your email address below to download the files.

By submitting your email address you agree that we can email you our Excel newsletter.

Watch the Video

Subscribe YouTube

Function Description
EXPAND Expands or pads an array to a specified number of rows and columns.
TOROW Returns the array in a single row. Useful for combining data across multiple columns and rows into a single row.
TOCOL Returns the array in a single column. Useful for combining data across multiple columns and rows into a single column.
WRAPROWS Lets you wrap (reshape) a row or column of values into rows, you specify the number of values in each row.
WRAPCOLS Lets you wrap (reshape) a row or column of values into columns, you specify the number of values in each column.
DROP Remove a specified number of contiguous rows or columns from the start or end of an array.
TAKE Extract a specified number of contiguous rows or columns from the start or end of an array.
CHOOSEROWS Extract rows from the specified column or columns.
CHOOSECOLS Extract columns from the specified rows or rows.
VSTACK Combine arrays arranged vertically (VSTACK) into a new single array.
HSTACK Combine arrays arranged horizontally (HSTACK) into a new single array.

Nested Array Shaping Functions

Individually the new array shaping functions are amazing, but team them up and you can create some super useful formulas.

In the table below I have a list of postcodes and the corresponding suburbs:

Array Shaping Function Example 1

I can pivot the layout with WRAPCOLS and TOROW so that the postcodes are now in a column like so:

Array Shaping Function Example 2

Or I can format it in a tabular layout with a column for the postcode and a column for the suburb with HSTACK, TOCOL and CHOOSEROWS:

Array Shaping Function Example 3

Notice how I used CHOOSEROWS to return the list of postcodes twice, hence the 1,1 in the CHOOSEROWS formula:

=HSTACK(TOCOL(CHOOSEROWS(C6:G6,1,1)),TOCOL(C7:G8))

Handling Missing Data

If there’s an uneven number of suburbs for each postcode you end up with blanks in the result:

Array Shaping Functions 4

We can filter out the blanks with the FILTER function:

Array Shaping Functions 5

FILTER checks for blanks by repeating the second array in HSTACK returned by TOCOL:

=FILTER(HSTACK(TOCOL(CHOOSEROWS(C31:G31,1,1,1,1)),TOCOL(C32:G35)), TOCOL(C32:G35)<>"")

AUTHOR Mynda Treacy Co-Founder / Owner at My Online Training Hub

CIMA qualified Accountant with over 25 years experience in roles such as Global IT Financial Controller for investment banking firms Barclays Capital and NatWest Markets.

Mynda has been awarded Microsoft MVP status every year since 2014 for her expertise and contributions to educating people about Microsoft Excel.

Mynda teaches several courses here at MOTH including Excel Expert, Excel Dashboards, Power BI, Power Query and Power Pivot.

2 thoughts on “New Array Shaping Excel Functions”

  1. There might be a use for EXPAND involving a problem needing matrix math operations on two arrays on unequal size. I can’t think of a practical example, though.

    Reply

Leave a Comment

Current ye@r *