Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-16-2021, 12:13 AM
Marcia's Avatar
Marcia Marcia is offline Remove extra delimiters in power query from merged columns with null values Windows 7 32bit Remove extra delimiters in power query from merged columns with null values Office 2013
Expert
Remove extra delimiters in power query from merged columns with null values
 
Join Date: May 2018
Location: Philippines
Posts: 526
Marcia has a spectacular aura aboutMarcia has a spectacular aura aboutMarcia has a spectacular aura about
Default Remove extra delimiters in power query from merged columns with null values

Hi. I have merged five columns by power query in both add column and transform tab. Some of the cells have null values and the result was like:


Abc;;klm;;
Any idea on how to remove the extra delimeters in the PQ?
Thank you.
Reply With Quote
  #2  
Old 02-16-2021, 09:02 AM
p45cal's Avatar
p45cal p45cal is offline Remove extra delimiters in power query from merged columns with null values Windows 10 Remove extra delimiters in power query from merged columns with null values Office 2019
Expert
 
Join Date: Apr 2014
Posts: 863
p45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant future
Default

try:
Code:
Result = Table.RemoveColumns(Table.AddColumn(Table.CombineColumnsToRecord(PreviousStep,"merged",{"Hdr1","Hdr2","Hdr3","Hdr4","Hdr5","Hdr6"}), "Custom", each Text.Combine(List.RemoveNulls(Record.ToList([merged])),";")),{"merged"})
where {"Hdr1","Hdr2","Hdr3","Hdr4","Hdr5","Hdr6"} is the list of column headers you want to merge and Custom is the name of the resultant column. The header merged can be anything as long as it is the same throughout; it really doesn't matter what it's called since it's created then deleted in the same line (of course it mustn't be the same as another pre-existing column name).


There are probably better/more elegant ways!
Reply With Quote
  #3  
Old 02-16-2021, 09:48 AM
p45cal's Avatar
p45cal p45cal is offline Remove extra delimiters in power query from merged columns with null values Windows 10 Remove extra delimiters in power query from merged columns with null values Office 2019
Expert
 
Join Date: Apr 2014
Posts: 863
p45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant future
Default

Quote:
Originally Posted by p45cal View Post
There are probably better/more elegant ways!
eg. with:

Code:
Result = Table.AddColumn(PreviousStep, "Custom", each Text.Combine(List.Select({[Hdr1],[Hdr2],[Hdr3],[Hdr4],[Hdr5],[Hdr6]}, each _<> "" and _ <> null),";"))
Reply With Quote
  #4  
Old 02-18-2021, 09:33 PM
Marcia's Avatar
Marcia Marcia is offline Remove extra delimiters in power query from merged columns with null values Windows 7 32bit Remove extra delimiters in power query from merged columns with null values Office 2013
Expert
Remove extra delimiters in power query from merged columns with null values
 
Join Date: May 2018
Location: Philippines
Posts: 526
Marcia has a spectacular aura aboutMarcia has a spectacular aura aboutMarcia has a spectacular aura about
Default

The error message says: could not find Table.CombineColumnsToRecord.....
Reply With Quote
  #5  
Old 02-18-2021, 10:52 PM
p45cal's Avatar
p45cal p45cal is offline Remove extra delimiters in power query from merged columns with null values Windows 10 Remove extra delimiters in power query from merged columns with null values Office 2019
Expert
 
Join Date: Apr 2014
Posts: 863
p45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant future
Default

Try the one in the next message then...
Reply With Quote
  #6  
Old 02-18-2021, 11:11 PM
Marcia's Avatar
Marcia Marcia is offline Remove extra delimiters in power query from merged columns with null values Windows 7 32bit Remove extra delimiters in power query from merged columns with null values Office 2013
Expert
Remove extra delimiters in power query from merged columns with null values
 
Join Date: May 2018
Location: Philippines
Posts: 526
Marcia has a spectacular aura aboutMarcia has a spectacular aura aboutMarcia has a spectacular aura about
Default

Quote:
Originally Posted by p45cal View Post
Try the one in the next message then...
Token comma error in the second expression.
Reply With Quote
  #7  
Old 02-19-2021, 02:18 AM
p45cal's Avatar
p45cal p45cal is offline Remove extra delimiters in power query from merged columns with null values Windows 10 Remove extra delimiters in power query from merged columns with null values Office 2019
Expert
 
Join Date: Apr 2014
Posts: 863
p45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant future
Default

Supply a little test file.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove delimiters in merged columns in power query when null Marcia Excel 2 11-06-2020 09:42 PM
Power Query to combine multiple tables of unequal number of columns ProudLiberal Excel 1 01-07-2020 07:54 PM
Remove extra delimiters in power query from merged columns with null values How to unmerge all merged cell and fill them with the merged values? Bumba Excel Programming 1 11-10-2019 11:36 AM
Query and Power Query not working Excel 2016 bl10 Excel 0 07-22-2016 06:25 PM
Remove extra delimiters in power query from merged columns with null values Display Null Values in Pivot as 0 lornalou Excel 2 06-02-2016 10:39 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft