Forum Discussion
SanthoshKunder
Sep 29, 2023Iron Contributor
EXPAND() function
Hi, and thanks in advance for any assistance. Can anyone provide information about the EXPAND() function? I'm looking to understand its use cases and how it can be applied in the dynamic array sp...
- Sep 29, 2023
Patrick2788
Sep 29, 2023Silver Contributor
I use EXPAND for a few reasons:
1. Avoiding 'Jagged' arrays. The by-the-book use here, nothing fancy. You might also see error checking used in place of EXPAND as such:
=IFNA(VSTACK(Regions,Oceans),"")
2. Adding padding to an array. In this case, blanks after each item:
=TOCOL(EXPAND(names,,2,""))
3. Unpacking scalars. Essentially, this function repeats a given item x number of times based on the color looked up:
=LET(
Unpack, LAMBDA(a, v,
LET(
k, XLOOKUP(v, colors, counts),
VSTACK(a, EXPAND(v, k, , v))
)
),
REDUCE("Colors Unpacked", colors, Unpack)
)
EXPAND's weakness is the inability to accept arrays in the pad_with argument.