How do you get rid of extra delimiters when merging columns?

Monsignor

Board Regular
Joined
May 30, 2011
Messages
162
In a situation where not every column has a value, the Merge Columns feature adds a delimiter even if a cell is blank. Thus a result can be like:

IL,KS,,,,NY
,,,,,FL
,CA,,,,
GA,FL,,DC,KS,CA

rather than:
IL,KS,NY
FL
CA
GA,FL,DC,KS,CA


Basically, it'd be nice to recreate the new TEXTJOIN function and include the option to Ignore Blanks.
 
Oh yep sure.
In this case, the (_) represents the List argument of the "Combiner" function I have defined as the 3rd argument of Table.CombineColumns.
The "each _" syntax is a simplified way of defining a function that takes one argument (see section 9.7 of language specification).

The 3rd argument of Table.CombineColumns (the "Combiner" function) must be a function that takes a single List argument, and whatever this function returns will be put in the merged column.

The List argument that is passed to the Combiner function, for each row, will be the list of values from the fields that you have chosen to combine (specified in the 2nd argument of Table.CombineColumns).

Basically, the Combiner function in this case in words is "First apply List.RemoveNulls to the list (represented by _), then combine the result with comma delimiter".

These two versions of the Combiner function are equivalent.

  1. ( ListOfItems ) => Combiner.CombineTextByDelimiter(",", QuoteStyle.None)(List.RemoveNulls( ListOfItems ))
  2. each Combiner.CombineTextByDelimiter(",", QuoteStyle.None)(List.RemoveNulls( _ ))

Cheers,
Owen
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,223,247
Messages
6,171,004
Members
452,374
Latest member
keccles

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