Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove only consecutive blanks from VSTACK output

I often VSTACK columns and remove empty results with FILTER like so:

FILTER(VSTACK(<filtered_column_1>;<filtered_column_2>);
VSTACK(<filtered_column_1>;<filtered_column_2>)<>0)

But I've come accross a case in which I actually want to keep blanks that are not consecutive.

Unfiltered VSTACK output:

1
2
<blank>
<blank>
<blank>
2
2
3
<blank>
3

Desired filtered VSTACK output:

1
2
<blank>
2
2
3
<blank>
3

It should technically be easy comparing each value to the previous one, but my problem is that I don't know how to reference the VSTACK output columns for comparison in the FILTER "include" argument, specially considering the columns I'm feeding as arguments to the VSTACK are not referenceable columns but rather filtered columns themselves.

FILTER(VSTACK(<filtered_column_1>;<filtered_column_2>);
<what do I do here in the "include" argument?>)

Any ideas?

like image 743
HigoChumbo Avatar asked Aug 05 '26 18:08

HigoChumbo


1 Answers

Try the following formula-

=LET(x,VSTACK("",1,2,"","","",2,2,3,""),
z,MAP(SEQUENCE(ROWS(x)),LAMBDA(y,IF(AND(INDEX(x,y)="",INDEX(x,y-1)=""),FALSE,TRUE))),
FILTER(x,z))

Replace VSTACK("",1,2,"","","",2,2,3,"") with your VSTACK() formula.

enter image description here

like image 176
Harun24hr Avatar answered Aug 08 '26 18:08

Harun24hr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!