Delimiting a concatenated multi-column, multi-row output (TEXTJOIN + FILTER + INDEX + SEQUENCE)

AOB

Well-known Member
Joined
Dec 15, 2010
Messages
673
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
I have a multi-column table listing (among other things) names and associated groups, á la :

GroupSomeField1SomeField2SomeField3First NameLast NameSomeField4SomeFieldX
AfoobarfoobarHomerSimpsonfoobar
AfoobarfoobarFredFlintstonefoobar
BfoobarfoobarPeterGriffinfoobar
BfoobarfoobarDangerMousefoobar
BfoobarfoobarYogiBearfoobar

I'm trying to put together a formula that returns a concatenated list of names (i.e. multiple columns from multiple matches into a single delimited list of names)

I have this so far :

Excel Formula:
=TEXTJOIN(" ",TRUE,FILTER(INDEX(tblMyTable,SEQUENCE(ROWS(tblMyTable)),{5,6}),tblMyTable[Group]=GroupName))

But that (obviously) just delimits each first and last name with a space, á la :

GroupName = "A" : Homer Simpson Fred Flintstone
GroupName = "B" : Peter Griffin Danger Mouse Yogi Bear

I'd like to delimit each name "pair" (e.g. First Name + Last Name) with a comma (or some separating character) to achieve something like this :

GroupName = "A" : Homer Simpson, Fred Flintstone
GroupName = "B" : Peter Griffin, Danger Mouse, Yogi Bear

Any suggestions as to how I could modify my formula to delimit the output in this manner?

Thanks!
 
How about
Fluff.xlsm
ABCDEFGH
1GroupSomeField1SomeField2SomeField3First NameLast NameSomeField4SomeFieldX
2AfoobarfoobarHomerSimpsonfoobar
3AfoobarfoobarFredFlintstonefoobar
4BfoobarfoobarPeterGriffinfoobar
5BfoobarfoobarDangerMousefoobar
6BfoobarfoobarYogiBearfoobar
7
8
9
10AHomer Simpson, Fred Flintstone
11BPeter Griffin, Danger Mouse, Yogi Bear
Data
Cell Formulas
RangeFormula
B10:B11B10=TEXTJOIN({" ",", "},,FILTER(CHOOSECOLS(tblMyTable,5,6),tblMyTable[Group]=A10))
 
  • Like
Reactions: AOB
Upvote 0
Solution
Well that is pretty freaking awesome @Fluff thank you SO much - not only have you solved the problem, you've introduced me to CHOOSECOLS which I wasn't familiar with and, now, adore, and the formula is significantly simpler to read as well.

This is brilliant, thank you!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Sorry to resurrect this again @Fluff (and let me know if it should move to its own thread)

Been playing around with the formula and was curious to know if/how to use the CHAR() function within the delimiter array for the TEXTJOIN() function?

So, for example, if, instead of delimiting the "second" entry from the FILTER output with a comma :

Excel Formula:
=TEXTJOIN({" ",", "},,FILTER(CHOOSECOLS(tblMyTable,5,6),tblMyTable[Group]=A10))

One wanted to use a carriage return / line feed (i.e. a new line within the same cell) instead, the logical thing (to me) would be to replace the comma with CHAR(10), á la :

Excel Formula:
=TEXTJOIN({" ",CHAR(10)},,FILTER(CHOOSECOLS(tblMyTable,5,6),tblMyTable[Group]=A10))

But Excel doesn't like that ("There's a problem with this formula...")

How might one use an ASCII character in place of a standard character within that array?
 
Upvote 0
The {} is an array constant, so anything inside it must be a constant (not a formula).
How about
Excel Formula:
=TEXTJOIN(hstack(" ",CHAR(10)),,FILTER(CHOOSECOLS(tblMyTable,5,6),tblMyTable[Group]=A10))
 
  • Like
Reactions: AOB
Upvote 0
Stunning 🤩 Thank you!
 
Upvote 0

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