Power Query - Combine columns, ignoring nulls

Darkstar_

New Member
Joined
Nov 24, 2018
Messages
13
I have a series of columns I wish to join. All containing text.
For each one I want a delimiter of the pipe symbol.

I merge the columns but I don't get what I want. Here is example of the data:

MonTuesWedThurFri
MonTuesWed
Mon

When I merge column I get this

Mon|Tues|Wed|Thur|Fri
Mon|Tues|Wed||
Mon||||


When all I want is:

Mon|Tues|Wed|Thur|Fri
Mon|Tues|Wed
Mon

I can do this in a flash in Excel with TextJoin, as that gives me the option to ignore blanks.

Any solution?

Below is my current code:

VBA Code:
let
    Source = OUTPUT,
    #"Merged Queries" = Table.NestedJoin(Source, {"Reference Document"}, LIVE_LINKS__LOCAL, {"Filename"}, "LIVE_LINKS__LOCAL", JoinKind.LeftOuter),
    #"Expanded LIVE_LINKS__LOCAL" = Table.ExpandTableColumn(#"Merged Queries", "LIVE_LINKS__LOCAL", {"Tax.2"}, {"Tax.2"}),
    #"Merged Columns" = Table.CombineColumns(#"Expanded LIVE_LINKS__LOCAL",{"Taxonomy", "Tax.2"},Combiner.CombineTextByDelimiter("|", QuoteStyle.None),"Taxonomy.1")
in
    #"Merged Columns"
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    #"Merged Columns" = Table.CombineColumns(Source,{"Column1", "Column2", "Column3", "Column4", "Column5"},Combiner.CombineTextByDelimiter("|", QuoteStyle.None),"Merged"),
    #"Replaced Value" = Table.ReplaceValue(#"Merged Columns","||","",Replacer.ReplaceText,{"Merged"})
in
    #"Replaced Value"
 
Upvote 0
Thank you, but that doesn't seem to work.
It only replaces two ||. I still get the | at the end of a row etc.
 
Upvote 0
I see the issue. Working on a solution. It occurs when there is an odd number of null cells
 
Upvote 0
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    #"Replaced Value" = Table.ReplaceValue(Source,null,"@@@###",Replacer.ReplaceValue,{"Column1", "Column2", "Column3", "Column4", "Column5"}),
    #"Merged Columns" = Table.CombineColumns(#"Replaced Value",{"Column1", "Column2", "Column3", "Column4", "Column5"},Combiner.CombineTextByDelimiter("|", QuoteStyle.None),"Merged"),
    #"Replaced Value1" = Table.ReplaceValue(#"Merged Columns","|@@@###","",Replacer.ReplaceText,{"Merged"})
in
    #"Replaced Value1"
 
Upvote 1
Please try


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    AMerge = Table.AddColumn(Source, "Merge", each Text.Combine( Record.ToList(_),"|"))
in
    AMerge
 
Upvote 0

Forum statistics

Threads
1,223,704
Messages
6,173,984
Members
452,540
Latest member
haasro02

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