Search code examples
google-sheetsfilterarray-formulastextjoin

Trouble with an ArrayFormula formula on Google Sheets


I'm currently using a formula that displays exactly what I want but I want this formula to work all the way down the column which is why I tried to use ArrayFormula but it doesn't work with Query.

The formula:

=TEXTJOIN(CHAR(10);TRUE;QUERY(DATA!$A$2:$FN;"SELECT FN WHERE K matches '"&$D2&"'"))

What I tried with ArrayFormula:

=Arrayformula(TEXTJOIN(CHAR(10);TRUE;QUERY(DATA!$A$2:$FN;"SELECT FN WHERE K matches '"&$D2&"'")))

Both formulas display the same result on the first cell only. How can I modify my formula to work on the entire column?

Sheet sample: https://docs.google.com/spreadsheets/d/1j2wqJwoCdxUuXDZ4_cC7sHHb5YybMqA42HfikN0Nijk/edit


Solution

  • You may try this in Cell_M2:

    =map(D2:D;lambda(Σ;if(Σ="";;textjoin(char(10);1;ifna(filter(DATA!FN:FN;DATA!K:K=Σ))))))
    

    enter image description here