{"id":2323,"date":"2020-04-05T04:04:09","date_gmt":"2020-04-05T04:04:09","guid":{"rendered":"https:\/\/portfolio.accrualhub.com\/powergi2\/?p=113"},"modified":"2025-04-02T22:01:21","modified_gmt":"2025-04-02T22:01:21","slug":"power-query-tip-how-to-combine-unformatted-tables-with-slightly-different-columns","status":"publish","type":"post","link":"https:\/\/powergi.net\/es\/blog\/power-query-tip-how-to-combine-unformatted-tables-with-slightly-different-columns\/","title":{"rendered":"Learn How to Combine Tables With Slightly Different Columns"},"content":{"rendered":"<div data-elementor-type=\"wp-post\" data-elementor-id=\"2323\" class=\"elementor elementor-2323\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-5e9ed2df elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"5e9ed2df\" data-element_type=\"section\" data-e-type=\"section\" data-settings='{\"jet_parallax_layout_list\":[]}'>\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-78d0a669\" data-id=\"78d0a669\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-56efb657 elementor-widget elementor-widget-text-editor\" data-id=\"56efb657\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\n<p class=\"wp-block-paragraph\">Excel\u2019s Power Query allows you to append several files from a folder using the \u201cGet Data-&gt; From File \u2013 &gt; From Folder\u201d option. One of the main requirements to achieve this is that all the files in the folder need to have the same format when it comes to columns, <strong>but what happens when some of your files have less columns than the main one?<\/strong><\/p>\n\n<p class=\"wp-block-paragraph\">Let\u2019s see how to solve this problem using the below example:<\/p>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-115\" src=\"https:\/\/powergi.net\/wp-content\/uploads\/2026\/07\/1-1024x563-1.webp\" alt=\"\">\n<figcaption>We have three files with 5 columns in common, but there are a couple that are not present in all the files: Contact2, ContactType2 and Address Line 2.<\/figcaption>\n<\/figure>\n\n<p class=\"wp-block-paragraph\">If the data inside your files is formatted as an <strong>Excel Table<\/strong>, this shouldn\u2019t be an issue, because Excel will automatically recognize the tables and headers and place them based on the column name and not on position:<\/p>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-116\" src=\"https:\/\/powergi.net\/wp-content\/uploads\/2020\/04\/2-1024x223.png\" alt=\"\"><\/figure>\n<p>\u00a0<\/p><div id=\"seology-cta-1\">\t\t<div data-elementor-type=\"section\" data-elementor-id=\"7280\" class=\"elementor elementor-7280\" data-elementor-post-type=\"elementor_library\">\n\t\t\t<div class=\"elementor-element elementor-element-7e3f164 e-con-full e-flex e-con e-parent\" data-id=\"7e3f164\" data-element_type=\"container\" data-e-type=\"container\" data-settings='{\"background_background\":\"classic\",\"jet_parallax_layout_list\":[]}'>\n\t\t<div class=\"elementor-element elementor-element-9078c9f e-con-full e-flex e-con e-child\" data-id=\"9078c9f\" data-element_type=\"container\" data-e-type=\"container\" data-settings='{\"jet_parallax_layout_list\":[]}'>\n\t\t\t\t<div class=\"elementor-element elementor-element-7b99949 elementor-widget elementor-widget-heading\" data-id=\"7b99949\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<p class=\"elementor-heading-title elementor-size-default\">Automatiza las tareas que te ralentizan<\/p>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8e61db5 elementor-widget elementor-widget-heading\" data-id=\"8e61db5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<p class=\"elementor-heading-title elementor-size-default\">Libere el tiempo de su equipo y conc\u00e9ntrese en el trabajo estrat\u00e9gico con la automatizaci\u00f3n digital y rob\u00f3tica.<\/p>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-a578907 e-flex e-con-boxed e-con e-child\" data-id=\"a578907\" data-element_type=\"container\" data-e-type=\"container\" data-settings='{\"jet_parallax_layout_list\":[]}'>\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-e8c827b elementor-view-stacked elementor-shape-circle elementor-widget elementor-widget-icon\" data-id=\"e8c827b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"icon.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-wrapper\">\n\t\t\t<a class=\"elementor-icon\" href=\"#ctc_chat\">\n\t\t\t<i aria-hidden=\"true\" class=\"fab fa-whatsapp\"><\/i>\t\t\t<\/a>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d834237 elementor-view-stacked elementor-shape-circle elementor-widget elementor-widget-icon\" data-id=\"d834237\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"icon.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-wrapper\">\n\t\t\t<a class=\"elementor-icon\" href=\"https:\/\/powergi.net\/es\/contact\/\">\n\t\t\t<i aria-hidden=\"true\" class=\"far fa-envelope\"><\/i>\t\t\t<\/a>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<\/div>\n<p>However, if you\u2019re dealing with more complex data structures or integrating Power Query with other Microsoft tools, you might need additional expertise. That\u2019s where <a href=\"https:\/\/powergi.net\/es\/microsoft-power-platform-consulting-services\/\"><strong>Microsoft Power Platform consulting services<\/strong><\/a> can be useful in optimizing data transformation processes.<\/p>\n\n<p class=\"wp-block-paragraph\">But, if <a href=\"https:\/\/powergi.net\/es\/blog\/convert-excel-file-to-csv-format-with-power-automate-xlsx-to-csv\/\"><strong>your files are in csv<\/strong><\/a> format or if the data is <strong>not formatted <\/strong>as a table inside the file, this is how Power Query will place the data:<\/p>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-117\" src=\"https:\/\/powergi.net\/wp-content\/uploads\/2026\/07\/3-1024x330-1.webp\" alt=\"\">\n<figcaption>Columns data get mixed<\/figcaption>\n<\/figure>\n\n<p class=\"wp-block-paragraph\">The files were processed based on position and now we have Contact Type 2, Address Line 2 and Comments under the same column.<\/p>\n\n<p class=\"wp-block-paragraph\">The first thought would be to format the data in each of the files as tables, but what if you process 20-50 csv files a day? Nobody wants to manually manipulate 20 different files, let\u2019s better have Power Query do the trick for us!<\/p>\n\n<h2 class=\"wp-block-heading\"><strong>The solution: Promote Headers in the \u201cTransform Sample File\u201d <\/strong><\/h2>\n\n<p class=\"wp-block-paragraph\">After connecting to a folder, in the queries section, you will see a query called \u201cTransform Sample File\u201d, open it and you will notice that the column names from our files are being set as the first row, and not as actual headers. Let\u2019s set this row as our header.<\/p>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-119\" src=\"https:\/\/powergi.net\/wp-content\/uploads\/2026\/07\/4-1024x472-1.webp\" alt=\"\"><\/figure>\n\n<p class=\"wp-block-paragraph\">We do this by using the \u201cUse First Row as Headers\u201d option in the ribbon, after clicking it, you should see the correct column names but there will also be a new step called \u201cChanged Type\u201d, \u00a0<strong>make sure to delete this step from this sample query<\/strong>. (Note: this needs to be removed because this step is applying format to each column based on their name, for example, if the sample file has a \u201cContact2\u201d column, it will always try to format it in ALL your files, and if your file doesn\u2019t have it, it will error out).\u00a0<\/p>\n\n<p class=\"wp-block-paragraph\">This is how the final sample query should look:\u00a0\u00a0<\/p>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-120\" src=\"https:\/\/powergi.net\/wp-content\/uploads\/2020\/04\/6-1024x229.png\" alt=\"\"><\/figure>\n\n<p class=\"wp-block-paragraph\">Now, let\u2019s go back to the main query that is combining all the files. You will see an \u201cExpression error\u201d showing up instead of the results, this is because this query is referencing the old column names (Column1, Column2, Column3\u2026), to fix this error, just delete the \u201cChanged Type\u201d step.<\/p>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-121\" src=\"https:\/\/powergi.net\/wp-content\/uploads\/2020\/04\/7-1024x296.png\" alt=\"\"><\/figure>\n\n<p class=\"wp-block-paragraph\">After that, you will see how the headers are correctly placed and it\u2019ll show \u201cnull\u201d when the column is missing from a source file.\u00a0<\/p>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-122\" src=\"https:\/\/powergi.net\/wp-content\/uploads\/2020\/04\/8-1024x172.png\" alt=\"\"><\/figure>\n\n<p class=\"wp-block-paragraph\">One caveat to this is that the \u201cSample file\u201d should be a file containing the highest number of columns.<br>This can also be automated but requires an additional step, we have created an entry on the topic: <br><br><a href=\"https:\/\/powergi.net\/es\/blog\/power-query-files-from-folder-make-the-sample-file-the-one-with-the-most-columns\/\">https:\/\/powergi.net\/blog\/power-query-files-from-folder-make-the-sample-file-the-one-with-the-most-columns\/<\/a><\/p>\n\n<p class=\"wp-block-paragraph\">\u00a0<\/p><div id=\"seology-cta-2\">\t\t<div data-elementor-type=\"section\" data-elementor-id=\"7283\" class=\"elementor elementor-7283\" data-elementor-post-type=\"elementor_library\">\n\t\t\t<div class=\"elementor-element elementor-element-7e3f164 e-con-full e-flex e-con e-parent\" data-id=\"7e3f164\" data-element_type=\"container\" data-e-type=\"container\" data-settings='{\"background_background\":\"classic\",\"jet_parallax_layout_list\":[]}'>\n\t\t<div class=\"elementor-element elementor-element-9078c9f e-con-full e-flex e-con e-child\" data-id=\"9078c9f\" data-element_type=\"container\" data-e-type=\"container\" data-settings='{\"jet_parallax_layout_list\":[]}'>\n\t\t\t\t<div class=\"elementor-element elementor-element-7b99949 elementor-widget elementor-widget-heading\" data-id=\"7b99949\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<p class=\"elementor-heading-title elementor-size-default\">\u00bfEst\u00e1 su negocio preparado para la automatizaci\u00f3n?<\/p>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8e61db5 elementor-widget elementor-widget-heading\" data-id=\"8e61db5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<p class=\"elementor-heading-title elementor-size-default\">Automatiza procesos con Microsoft Power Platform.<\/p>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-a578907 e-flex e-con-boxed e-con e-child\" data-id=\"a578907\" data-element_type=\"container\" data-e-type=\"container\" data-settings='{\"jet_parallax_layout_list\":[]}'>\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-e8c827b elementor-view-stacked elementor-shape-circle elementor-widget elementor-widget-icon\" data-id=\"e8c827b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"icon.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-wrapper\">\n\t\t\t<a class=\"elementor-icon\" href=\"#ctc_chat\">\n\t\t\t<i aria-hidden=\"true\" class=\"fab fa-whatsapp\"><\/i>\t\t\t<\/a>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d834237 elementor-view-stacked elementor-shape-circle elementor-widget elementor-widget-icon\" data-id=\"d834237\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"icon.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-wrapper\">\n\t\t\t<a class=\"elementor-icon\" href=\"https:\/\/powergi.net\/es\/contact\/\">\n\t\t\t<i aria-hidden=\"true\" class=\"far fa-envelope\"><\/i>\t\t\t<\/a>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<\/div>\n\n<h2 class=\"wp-block-heading\"><strong>Beyond promoting headers<\/strong><\/h2>\n\n<p class=\"wp-block-paragraph\">Another scenario where you may want to modify the \u201cTransform sample file\u201d query is when files have some rows on top of the table as a \u201cDocument Header\u201d, if your data is not formatted as an excel table, same issue will happen.<\/p>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-123\" src=\"https:\/\/powergi.net\/wp-content\/uploads\/2026\/07\/9-1024x401-1.webp\" alt=\"\">\n<figcaption>Power Query will bring rows we don\u2019t need, and place our columns based on position, which we don\u2019t want.<\/figcaption>\n<\/figure>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-124\" src=\"https:\/\/powergi.net\/wp-content\/uploads\/2026\/07\/10-1024x601-1.webp\" alt=\"\"><\/figure>\n\n<p class=\"wp-block-paragraph\">The underlying solution for this scenario is the same, you need to modify the \u201cTransform Sample File\u201d query, but adding a couple more basic steps (depending on your specific files). In this specific case, we can remove \u201cnull\u201d values in Column4 and that will make all unnecessary records go away.<\/p>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-125\" src=\"https:\/\/powergi.net\/wp-content\/uploads\/2020\/04\/11-1024x323.png\" alt=\"\"><\/figure>\n\n<p class=\"wp-block-paragraph\">After removing nulls, promote headers and don\u2019t forget to remove the \u201cChange type\u201d step (Like we did in previous example). <br><br>After that, go back to the main query and remove the existing \u201cChange Type\u201d step that is referring to the old column order.<\/p>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-127\" src=\"https:\/\/powergi.net\/wp-content\/uploads\/2020\/04\/13-1024x332.png\" alt=\"\"><\/figure>\n\n<p class=\"wp-block-paragraph\">Now, you\u2019re all set, unnecessary records have been removed and the headers are correctly assigned.<\/p>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>Combining files with Power Query is great but what happens when some unformatted files have less columns?<\/p>","protected":false},"author":2,"featured_media":2619,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"glossary_letter":"","footnotes":""},"categories":[25],"tags":[13,24,16,19],"class_list":["post-2323","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-power-query-cat","tag-automation","tag-data-transformation","tag-excel","tag-power-query"],"glossary_letter":null,"rank_math_title":null,"rank_math_description":null,"rank_math_focus_keyword":null,"_links":{"self":[{"href":"https:\/\/powergi.net\/es\/wp-json\/wp\/v2\/posts\/2323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/powergi.net\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/powergi.net\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/powergi.net\/es\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/powergi.net\/es\/wp-json\/wp\/v2\/comments?post=2323"}],"version-history":[{"count":0,"href":"https:\/\/powergi.net\/es\/wp-json\/wp\/v2\/posts\/2323\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/powergi.net\/es\/wp-json\/wp\/v2\/media\/2619"}],"wp:attachment":[{"href":"https:\/\/powergi.net\/es\/wp-json\/wp\/v2\/media?parent=2323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/powergi.net\/es\/wp-json\/wp\/v2\/categories?post=2323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/powergi.net\/es\/wp-json\/wp\/v2\/tags?post=2323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}