I have this query formula:
IF(A8="","",IFNA(ARRAYFORMULA(TEXTJOIN(", ",TRUE,QUERY(Sheet6!B5:K,"SELECT F, I, J, K WHERE C = DATE'" & TEXT(A8,"yyyy-mm-dd") & "' AND G = 2",0)))))
It uses TEXTJOIN
to return the values in a single cell like this:
A1, B1, C1, D1, A2, B2, C2, D2, A3, B3, C3, D3
I want this to remain in a single cell, but for the cell to show with line breaks as follows:
A1, B1, C1, D1 A2, B2, C2, D2 A3, B3, C3, D3
A1, A2 and A3 are names and contain spaces.
How can I adjust this to match the 2nd excerpt? Any help will be greatly appreciated.
Try using a Regular expression to replace every 4th comma with the CHAR(10)
value. This is what I believe you are looking for:
=REGEXREPLACE(TEXTJOIN(", ", TRUE, QUERY(Sheet6!B5:K, "SELECT F, I, J, K WHERE C = DATE'" & TEXT(A8, "yyyy-mm-dd") & "' AND G = 2", 0)),"((?:[^,]*,){3}[^,]*), ", "$1"&CHAR(10))
,
.