Forum Discussion
Weird Results from Array Manipulation - Any ideas on why?
nkal24 The explanation I provided was based on my own observations and conclusions after testing the functions in various ways. I think the official term for the described behavior is "broadcasting". The following resources might help to explain the basic concept:
- https://exceljet.net/glossary/broadcasting
- https://fastexcel.wordpress.com/2015/01/11/using-constant-arrays-and-array-expressions-in-excel-formulas/
- https://numpy.org/doc/stable/user/basics.broadcasting.html
While these sites make no mention of the CHOOSE function directly, the same basic principles apply. When an array object is passed to the index_num argument of CHOOSE (e.g. {1} instead of 1), all of the value arguments are automatically resized via broadcasting. A value argument containing a single column of data (vertical vector) is broadcast across to fill the same number of columns as the argument with the most columns, whereas a value argument containing a single row of data (horizontal vector) is broadcast down to fill the same number of rows as the argument with the most rows. When arrays with mismatched dimensions are present (e.g. value1 is 3 columns wide and value2 is 4 columns wide), the additional rows and/or columns will be filled with #N/A errors.
An example of one possible use for this can be found here:
I hope that helps. Cheers!
- nkal24Aug 04, 2024Brass ContributorThank you very much djclements! This is indeed very helpful. I look forward to learning from your future posts.