I have rows of data like so:
a|b|1|c|d
a|b|1, 2|c|d
e|f||g|h
I am using BYROW to split them:
=BYROW(
A2:A,
LAMBDA(
row,
SPLIT(
row,
"|",
,
FALSE
)
)
)
This works but then for cells that LOOK like numbers it converts to numbers. This breaks a QUERY formula I am trying to wrap around.
=QUERY(
BYROW(
A2:A,
LAMBDA(
row,
SPLIT(
row,
"|",
,
FALSE
)
)
),
"SELECT * WHERE Col3 IS NOT NULL"
)
query
does not like mixed data types in a single column (Query is ignoring string (non numeric) value) so the above function returns all the rows but does not return value in cells that don't have a number. So this is the output I get:
a | b | 1 | c | d |
a | b | c | d |
But the expected output is:
a | b | 1 | c | d |
a | b | 1, 2 | c | d |
I've concluded this is cause SPLIT converts to number. I can't use TO_TEXT
becuase some columns have dates that I do want to convert.
instead buggy query, try non-invasive:
=LET(x, BYROW(A2:A, LAMBDA(r, SPLIT(r, "|",, ))), FILTER(x, INDEX(x,,3)<>""))
but if you really wish for query:
=INDEX(LET(x, QUERY(BYROW(SUBSTITUTE(A2:A, ",", "×"),
LAMBDA(r, SPLIT(r, "|",, )))&"", "where Col3 is not null", ),
IF((IFERROR(x*1)="")+(x=""), SUBSTITUTE(x, "×", ","), IF((x*1)>40000, TEXT(x, "dd/mm/yyyy"), x*1))))