Forum Discussion
qazzzlyt
Nov 30, 2024Copper Contributor
Formula VSTACK/HSTACK with blank array
I have a formula =VSTACK(a,b,c,d), while length of each array is not fixed. Now, sometimes, let's say d is blank, or N/A. I want the result to be the stack of a+b+c. One solution is to use a IFERRO...
- Dec 02, 2024
As variant
=LET( FilterRange, LAMBDA(rng,id,name, IFERROR( FILTER(rng, CHOOSECOLS(rng, id) = name ), "⚽" ) ), Combined, VSTACK( FilterRange( A1:B1000, 1, "Bird" ), FilterRange( D1:E1000, 1, "Dog" ) ), FILTER( Combined, NOT( ISNA( CHOOSECOLS(Combined, 2 ) ) ) ) )
qazzzlyt
Dec 02, 2024Copper Contributor
Thank you all. See attached sample.
I want to take Birds from Zoo A and Dogs from Zoo B.
However, there is no Dog in Zoo B.
Solution A does not work. One #CALC! will stop entire VSTACK()
In solution B, I have to Filter() in separate cells first, then VSTACK() them.
It seems there is no elegant way if I have more Zoos.
Detlef_Lewin
Dec 04, 2024Silver Contributor
Another variant.
=LET(
a,VSTACK(
EXPAND(FILTER(A2:B10,A2:A10="Bird",""),,2,""),
EXPAND(FILTER(D2:E10,D2:D10="Dog",""),,2,"")
),
b,-SUM(--(a=""))/2,
c,DROP(a,b),
c)