Hi,
I am seeing strange behaviour with TEXTSPLIT which seems incorrect to me, particularly because the same calculations work when I use TEXTBEFORE and TEXTAFTER instead.
I am not looking to solve the particular examples posted, but rather some confirmation whether you agree that this is incorrect behaviour and a bug which should be reported to Microsoft.
The examples below are minimal example to reproduce the behaviour. I stumbled across this in some business logic which was giving incorrect results (and which was much more involved). I haven't been able to spot any pattern in the behaviour so I don't know how to protect myself against being bitten by this bug again in future (other than of course using TEXTBEFORE and TEXTAFTER instead, but that is more to type and also not always equivalent when you want to split into more than two fields).
Does anyone have any explanations or can point out my misconception before I report this as a bug to Microsoft?
Full Table of Examples
To simplify the formulas, I created the following APPLYCOL utility function. It basically functions like BYCOL but lets you return multi-row arrays instead of just a single row.
The APPLYCOL function is defined as follows:
a=1,b=2 | ||||
Formula | Output | Expected | Status | Comment |
=LET( | {"a","b"} | {"a","b";"1","2"} | FAIL | Why doesn't this work? |
=LET( | {"a","b"} | {"a","b";"1","2"} | FAIL | Or at least this? |
=LET( | {"a","b"} | {"a","b";"1","2"} | FAIL | Or this? |
=LET( | {"a","b";"1","2"} | {"a","b";"1","2"} | PASS | This works but doesn't scale to more rows. |
=LET( | {"a","b";"1","2"} | {"a","b";"1","2"} | PASS | This works and led me to discover the next one. |
=LET( | {"a","b";"1","2"} | {"a","b";"1","2"} | PASS | Bizarrely this works! |
=LET( | {"a","b"} | {"a","b";"1","2"} | FAIL | But this doesn't. |
=LET( | {"a","b"} | {"a","b";"1","2"} | FAIL | Why doesn’t this work even though we're splitting by row delimiter? |
=LET( | {"a","b"} | {"a","b";"1","2"} | FAIL | Why doesn’t this work even though we're splitting by row delimiter? |
=LET( | {"a","b";"1","2"} | {"a","b";"1","2"} | PASS | The fact that this works seems to really point the finger at TEXTSPLIT as the problem. |
=LET( | {"a","b";"1","2"} | {"a","b";"1","2"} | PASS | Here TEXTSPLIT works again. Why? Because it's inside a MAP? |
=LET( | {"a","b"} | {"a","b";"1","2"} | FAIL | Why doesn't this work when the previous line worked? |
=LET( | {"a","b";"1","2"} | {"a","b";"1","2"} | PASS | |
=LET( | {"a","b";"1","2"} | {"a","b";"1","2"} | PASS | |
=LET( | {"a","b";"1","2"} | {"a","b";"1","2"} | PASS | |
=LET( | {"a","b";"1","2"} | {"a","b";"1","2"} | PASS | Works as expected. |
=LET( | {"a","b"} | {"a","b";"1","2"} | FAIL | I'm surprised even this doesn't work. |
=LET( | {"a","b";"1","2"} | {"a","b";"1","2"} | PASS | |
=LET( | {1,1} | {2,2} | FAIL | It's weird that with APPLYCOL the COUNTA is only seing a 1-element array. |
=LET( | {2,2} | {2,2} | PASS | With MAP, COUNTA sees a 2-element array as expected. |
Excel Version