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
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:
- 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.
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?
About the author
Hey, I’m Mark, and I run Excel Off The Grid.
My parents tell me that at the age of 7 I declared I was going to become a qualified accountant. I was either psychic or had no imagination, as that is exactly what happened. However, it wasn't until I was 35 that my journey really began.
In 2015, I started a new job, for which I was regularly working after 10pm. As a result, I rarely saw my children during the week. So, I started searching for the secrets to automating Excel. I discovered that by building a small number of simple tools, I could combine them together in different ways to automate nearly all my regular tasks. This meant I could work less hours (and I got pay raises!). Today, I teach these techniques to other professionals in our training program so they too can spend less time at work (and more time with their children and doing the things they love).
Do you need help adapting this post to your needs?
I'm guessing the examples in this post don't exactly match 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:
- Read other blogs, or watch YouTube videos on the same topic. You will benefit much more by discovering your own solutions.
- Ask the 'Excel Ninja' in your office. It's amazing what things other people know.
- 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.
- Use Excel Rescue, who are my consultancy partner. They help by providing solutions to smaller Excel problems.
Don't go yet, there is plenty more to learn on Excel Off The Grid. Check out the latest posts: