Antonio Padua
Antonio Padua

Reputation: 113

QUERY in ARRAYFORMULA to FILTER, JOIN and LEN

Given a table like this one:

A B C D E
1 Tese (2021/039-07964) (8146.000336/2021-60) Tema 1092
2 Afetado Tema 1092 Controvérsia 251
|3|Tese|(2021/0390796-6)||Tema 1093|Controvérsia 258|
|4|Afetado|||Tema 1093|Controvérsia 258|
|5|Tese|(2021/0390796-7)|(8146.000338/2021-50)||Controvérsia 238|

As long strings in Col A's rows are equal to "Tese", Col F should return a string (with line breaks) that compiles Col B to D strings that are not null in the same row.

So, row 1 of Col F should be:

F
(2021/0390796-4)
(8146.000336/2021-60)
Tema 1092

Row 2 of Col F should be:

F
(2021/039-07966)
Tema 1093
Controvérsia 258

And so on

I'm using a dropdown formula to do the job, which is working fine:

=IFERROR(IF(A1="Tese",JOIN(CHAR(10),FILTER(B1:E1, LEN(B1:E1))),""))

But it would be easier if it could be replaced by an array formula (the table is over 4,000 rows!).

I think it is possible to use a query, but I could not write the formula down.

The real table is here: link

Upvotes: 0

Views: 170

Answers (1)

JPV
JPV

Reputation: 27242

Clear all contents of column G and try in G1

={"Informações completa da tese"; INDEX(IF(A2:A="Tese"; SUBSTITUTE(SUBSTITUTE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(SUBSTITUTE(B2:F; " "; "$"));;ROWS(A2:A)))); " "; char(10)); "$"; " ");))}

See if that helps?

enter image description here

Upvotes: 2

Related Questions