TEXTSPLIT not working as expected inside of BYROW. Workaround?

felixstraube

Well-known Member
Joined
Nov 27, 2023
Messages
897
Office Version
  1. 365
Platform
  1. Windows
  2. Web
Hi all.
I was working on a LET formula that returned an array. Each element of the array contained text separated by semicolons. Then I wanted to work on each element with BYROW and separate the text of each element into an with TEXTSPLIT and work with the value of the last column. But, it wasn't working as expected. TEXTSPLIT apparently only returned the first element.

A simplified example would be the following:

As you can see, when I concatenate the input array with "" (which I suppose is something similar as the data I got in the formula I was working on), the formulas stops working as expected.
As if when the input is a range it works, but if it is an array (even a hard coded array, {"1;2";"3;4"}), it won't work.
Can you tell me why? Is there a workaround?

Thanks in advance!

Book9.xlsx
ABCD
1InputWorkingNot working
21;221
33;421
4
521
643
7
81|21
93|43
Sheet9
Cell Formulas
RangeFormula
C2:C3C2=LET( d, A2:A3, BYROW(d, LAMBDA(x, COLUMNS(TEXTSPLIT(x, ";")))) )
D2:D3D2=LET( d, A2:A3&"", BYROW(d, LAMBDA(x, COLUMNS(TEXTSPLIT(x, ";")))) )
C5:C6C5=LET( d, A2:A3, BYROW(d, LAMBDA(x, CHOOSECOLS(TEXTSPLIT(x, ";"),-1))) )
D5:D6D5=LET( d, A2:A3&"", BYROW(d, LAMBDA(x, CHOOSECOLS(TEXTSPLIT(x, ";"),-1))) )
C8:C9C8=LET( d, A2:A3, BYROW(d, LAMBDA(x, TEXTJOIN("|",,TEXTSPLIT(x, ";")))) )
D8:D9D8=LET( d, A2:A3&"", BYROW(d, LAMBDA(x, TEXTJOIN("|",,TEXTSPLIT(x, ";")))) )
Dynamic array formulas.
 
MAP is designed to process each element of an array one at a time. BYROW is designed to iterate through each row. If there's only one column, then one row = one cell, and TEXTSPLIT will work with that. It doesn't however like arrays. If you use something like:

Excel Formula:
=TEXTSPLIT({"A;B"},";")

it will only return A (hence your 1 column result)
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Thank you so much for your detailed and clear explanation. I really appreciate the time and effort you put into helping me understand this.
 
Upvote 0

Forum statistics

Threads
1,224,884
Messages
6,181,552
Members
453,052
Latest member
ezzat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top