{"id":3614,"date":"2021-09-27T17:13:46","date_gmt":"2021-09-28T00:13:46","guid":{"rendered":"https:\/\/SUMMALAI.COM\/?p=3614"},"modified":"2021-09-27T17:13:48","modified_gmt":"2021-09-28T00:13:48","slug":"how-to-merge-columns-to-create-a-new-column-in-power-query-power-bi-and-excel","status":"publish","type":"post","link":"https:\/\/SUMMALAI.COM\/?p=3614","title":{"rendered":"How to Merge Columns to Create a New Column in Power Query (Power BI and Excel)"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\" id=\"page-header\">Merge columns (Power Query)<\/h3>\n\n\n\n<p>Excel for Microsoft 365&nbsp;Excel 2021&nbsp;Excel 2019&nbsp;Excel 2016&nbsp;Excel 2013&nbsp;Excel 2010<\/p>\n\n\n\n<p>In Power Query, you can merge two or more columns in your query. You can merge columns to replace them with one&nbsp;merged column, or create a new merged column alongside the columns that are merged. You can only merge columns of a&nbsp;<strong>Text&nbsp;<\/strong>data type. The following data is used in the examples.<\/p>\n\n\n\n<p><strong>Tip&nbsp;<\/strong>&nbsp;&nbsp;&nbsp;It&#8217;s a good idea to create a new column and keep the original columns so you can better prevent refresh errors that might happen&nbsp;down the road.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/support.content.office.net\/en-us\/media\/68e65c28-0bf4-4326-9ce0-addd9d1c6481.png\" alt=\"Sample data used to explain the Merge command\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Merge columns to replace existing columns<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Merge columns to create a new column<\/h2>\n\n\n\n<p id=\"__goback\">You can insert a custom column into the query table and use a custom column&nbsp;to effectively merge two or more columns. In this case, the merged columns&nbsp;are still available along with the new merged column in the query table.<\/p>\n\n\n\n<p id=\"__goback_1\">In this&nbsp;example, we are merging&nbsp;<strong>OrderID&nbsp;<\/strong>and&nbsp;<strong>CustomerID&nbsp;<\/strong>separated by a space character.<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\"><li>To open a query, locate one previously loaded from the Power Query Editor, select a cell in the data, and then select&nbsp;<strong>Query&nbsp;<\/strong>&gt;&nbsp;<strong>Edit<\/strong>. For more information see&nbsp;<a href=\"https:\/\/support.microsoft.com\/en-us\/office\/create-load-or-edit-a-query-in-excel-power-query-ca69e0f0-3db1-4493-900c-6279bef08df4\">Create, load, or edit a query in Excel<\/a>.<\/li><li>Ensure that the columns that you want to merge are of&nbsp;<strong>Text<\/strong>&nbsp;data type. Select&nbsp;<strong>Transform&nbsp;<\/strong>&gt;&nbsp;<strong>Change Type<\/strong>&nbsp;&gt;&nbsp;<strong>Text<\/strong>.<\/li><li>Select&nbsp;&nbsp;<strong>Add Column&nbsp;<\/strong>&gt;&nbsp;<strong>&nbsp;Custom Column<\/strong>. The&nbsp;<strong>Custom Column<\/strong>&nbsp;dialog box appears.<\/li><li>In the&nbsp;<strong>Available Columns<\/strong>&nbsp;list, select the first column, and then select&nbsp;<strong>Insert<\/strong>. You can also double-click the first column.&nbsp;The column is added to the&nbsp;<strong>Custom Column Formula<\/strong>&nbsp;box immediately after the equal sign (=).<br><br><strong>Tip&nbsp;<\/strong>&nbsp;&nbsp;&nbsp;In the&nbsp;<strong>Custom Column Formula<\/strong>&nbsp;box, press Ctrl + Space to display columns and other formula elements.<\/li><li>In the&nbsp;<strong>Custom Column Formula<\/strong>&nbsp;box, enter an ampersand (&amp;) after the first column that you inserted.<br><br>The ampersand (&amp;) operator is used to combine values in Power Query in the same way&nbsp;as in Excel.<\/li><li>You can specify an additional separator, for example a space character, by entering &#8221; &#8221; after the&nbsp;ampersand (&amp;).<\/li><li>In the&nbsp;<strong>Custom Column Formula<\/strong>&nbsp;box, enter another ampersand (&amp;) after the space character.<\/li><li>In the&nbsp;<strong>Available Columns<\/strong>&nbsp;list, select the second column, and then select&nbsp;<strong>Insert<\/strong>. You can also double-click the second column.&nbsp;<br><br><img decoding=\"async\" src=\"https:\/\/support.content.office.net\/en-us\/media\/2d66b157-197d-4df5-b968-cbd4948a9dbd.png\" alt=\"Specify custom column formula to merge column values\"><\/li><li>Select&nbsp;<strong>OK.&nbsp;<\/strong><\/li><\/ol>\n\n\n\n<p><strong>Result<\/strong><br><br><img decoding=\"async\" src=\"https:\/\/support.content.office.net\/en-us\/media\/d5a34b8c-1e1d-4ea3-89f0-f56618357d4c.png\" alt=\"Custom merged column\"><\/p>\n\n\n\n<p>You can rename the custom column so that it is more meaningful to you. For more information, see&nbsp;<a href=\"https:\/\/support.microsoft.com\/en-us\/office\/rename-a-column-power-query-d72034d0-f271-4b62-bb57-1cce49d13a29\">Rename a column.<\/a><\/p>\n\n\n\n<p>Ref: https:\/\/support.microsoft.com\/en-us\/office\/merge-columns-power-query-80ec9e1e-1eb6-4048-b500-d5d42d9f0a8d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Merge columns (Power Query) Excel for Microsoft 365&nbsp;Excel 2021&nbsp;Excel 2019&nbsp;Excel 2016&nbsp;Excel 2013&nbsp;Excel 2010 In Power Query, you can merge two or more columns in your query. You can merge columns to replace them with one&nbsp;merged column, or create a new merged column alongside the columns that are merged. You can only merge columns of a&nbsp;Text&nbsp;data <a class=\"read-more\" href=\"https:\/\/SUMMALAI.COM\/?p=3614\">Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[10,18,621],"tags":[874,873],"class_list":["post-3614","post","type-post","status-publish","format-standard","hentry","category-microsoft","category-microsoft-office","category-power-bi","tag-merge-columns-in-power-bi","tag-merge-columns-in-power-query"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3614","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3614"}],"version-history":[{"count":2,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3614\/revisions"}],"predecessor-version":[{"id":3620,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3614\/revisions\/3620"}],"wp:attachment":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}