Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FLATTEN skipping blank cells without using UNIQUE

I'm trying to turn an array into a single column without blank cells, considering that the input will always have some blank cells and that there might be repeated values. I'm trying to use FLATTEN but it keeps the blanks and UNIQUE would kill the repeated values, so I can't use.

I also thought about using something like FLATTEN(QUERY(X:X, "select * WHERE col1,col2,col3,col4,col5 IS NOT NULL") but number of columns might be dynamic so I can't say precisely which columns to use.

My input:

enter image description here

Desired output:

enter image description here

Sample sheet here

Any clue?

like image 763
aabujamra Avatar asked Sep 12 '25 01:09

aabujamra


2 Answers

Use QUERY on the outside:

=QUERY(FLATTEN(YOUR-RANGE-HERE),"Select * WHERE Col1 Is Not Null")

I left an example in your spreadsheet, cell G2.

UPDATE 2023

One can now use the following new function:

=TOCOL(YOUR-RANGE-HERE, 1)

like image 189
Erik Tyler Avatar answered Sep 14 '25 22:09

Erik Tyler


=flatten(filter(A1:E10;not(isblank(A1:E10))))

or

=flatten(filter(A1:E10;len(A1:E10)))

or

=filter(flatten(A1:E10);len(flatten(A1:E10)))
like image 35
Ogi22 Avatar answered Sep 14 '25 21:09

Ogi22