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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,216,335
Messages
6,130,096
Members
449,557
Latest member
SarahGiles

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