Get our FREE VBA eBook of the 30 most useful Excel VBA macros.

Automate Excel so that you can save time and stop doing the jobs a trained monkey could do.

Claim your free eBook


Stop the auto Changed Type step in Power Query

Power Query in Excel and Power BI has an annoying default feature that automatically applies the Changed Type step even if we don’t want it. It generally occurs when creating new queries from non-database sources, but it also appears after some basic transformations.

In this post, I want to show you how to stop the automatic Changed Type step in Power Query.

Watch the video


Watch the video on YouTube.

Why is Changed Type a problem?

Changing data types in itself is a good thing. By defining data types, we tell Excel what calculations it can perform on each column. However, if not used at the correct point in our query, it can cause problems.

Let’s take a brief look at some of those problems.

Changing column names

If the Changed Type step is applied automatically on query creation, it is usually the first step explicitly referencing the column headers. Therefore, if our column names change, it will trigger an error on refresh. So, that isn’t good!

Creates unnecessary steps

If we have already defined the data type for a column, some transformations will trigger another change in data types.

For example, if we have a text column with the correct data type applied, splitting by a delimiter will add an additional (and unnecessary) Changed Type step.

Changed Type doesn’t always get it right

The automatic Changed Type transformation is based on Power Query’s assessment of the first 200 rows of data.

If we have an alphanumeric column, it should be treated as text. However, Power Query may decide it should be a whole number if no letters are found in the first 200 rows. This will also result in an error.

Also, just because something is numeric does not mean it should be a numeric data type. For example, references or anything containing leading zeros should be treated as text to ensure their value is correctly maintained. Yet, Power Query will often change these to numeric data types.

Inefficient refresh time

The order of steps affects the efficiency of a query. For example, if we have 1,000,000 rows of data and we want to filter on a single value which reduces the data to 100 rows. It is faster to apply the filter first, then change type on 100 records, rather than changing type on 1,000,000 rows then filtering.

It will be negligible for many datasets, but let’s not add additional delay into the process.

Often needs to be deleted manually

Because of the issues noted above, I find myself deleting the Changed Type step in most circumstances. Therefore, this adds extra manual effort.



How to stop the automatic Changed Type step?

To turn off the automatic Changed Type step in Power Query (this is the same in Excel and Power BI):

  • Within the Power Query Editor, click File > Options and Settings > Query Options
  • In the Global Data Load section, we have 3 options:
    Query Options Window
  • Select the 3rd option, Never detect column types and headers for unstructured sources, to stop the automatic application of the Changed Type step
  • If you want to decide on a Workbook by Workbook basis, select the 2nd option, Detect column types and headers for unstructured sources according to each file’s setting.
    To apply the setting for each Workbook, go to the Data Load from the Current Workbook section, uncheck the Detect column types and headers for unstructured sources option.
    Query Options Window - Workbook setting

Conclusion

See, all it takes is one simple setting, and we are now much more efficient. Of course, we still need to change types, but now we can decide when this happens.

If you want to know more about working with Power Query?



Get our FREE VBA eBook of the 30 most useful Excel VBA macros.

Automate Excel so that you can save time and stop doing the jobs a trained monkey could do.

Claim your free eBook


Don’t forget:

If you’ve found this post useful, or if you have a better approach, then please leave a comment below.

Do you need help adapting this to your needs?

I’m guessing the examples in this post didn’t exactly meet your situation.  We all use Excel differently, so it’s impossible to write a post that will meet everybody’s needs.  By taking the time to understand the techniques and principles in this post (and elsewhere on this site) you should be able to adapt it to your needs.

But, if you’re still struggling you should:

  1. Read other blogs, or watch YouTube videos on the same topic.  You will benefit much more by discovering your own solutions.
  2. Ask the ‘Excel Ninja’ in your office.  It’s amazing what things other people know.
  3. Ask a question in a forum like Mr Excel, or the Microsoft Answers Community.  Remember, the people on these forums are generally giving their time for free.  So take care to craft your question, make sure it’s clear and concise.  List all the things you’ve tried, and provide screenshots, code segments and example workbooks.
  4. Use Excel Rescue, who are my consultancy partner.   They help by providing solutions to smaller Excel problems.

What next?
Don’t go yet, there is plenty more to learn on Excel Off The Grid.  Check out the latest posts:

2 thoughts on “Stop the auto Changed Type step in Power Query

  1. Alexander HUNDT says:

    Great post indeed. Very useful to know these details on the behaviour of the EXCEL Power Query and how to modulate it.
    Thanks.

Leave a Reply

Your email address will not be published.