Digital asset

Power Query: Remove Numbers and Years from Column Headers Before Appending

Robin E Hunt

Robin E Hunt

Data pro that loves Power Query and the power it provides people at work.

ThinkDataSol

ThinkDataSol

Teaching data analytics across the world through our training and apprenticeship

See all products from ThinkDataSol

Same data. Different column headers. Now what?

I encountered this scenario while working with a dataset this week and thought it was worth sharing.

Sometimes, the data we download from systems contains variables in the column headers, such as years, dates, or other changing values. When we try to append these datasets in Power Query, mismatched column headers result in additional columns and unexpected null values.

In this quick tutorial, Robin Hunt demonstrates how to use Power Query M code to dynamically remove numbers and unwanted characters from column headers, making it easier to combine historical datasets for comprehensive analysis.

What you'll learn:

  • Why inconsistent column headers create problems when appending data

  • How Power Query handles mismatched column names

  • How to remove numbers and forward slashes from column headers

  • How to modify M code using the Advanced Editor

  • How referenced append queries respond to changes in source queries

  • Why reviewing your data types after transformations is important

  • How to use Microsoft Copilot to customize M code for your specific needs

We'll also explore how artificial intelligence can help us adapt reusable code without having to write everything from scratch.

This technique is applicable to Power Query in both Microsoft Excel and Power BI.

What's in this resource guide?

  • Access a video a walkthrough in under 10 minutes to learn how to remove those pesky values from column headers and prepare multiple datasets for appending in Power Query.

  • Get access to the sample data files used in the demonstration so you can follow along and practice.

  • Access step-by-step instructions and reusable M code to apply this technique to your own datasets.

Free

Learn how to remove unwanted values from column headers and append datasets using Power Query with this resource guide.

By continuing, you agree to Maven's Terms and Privacy Policy.