Sub topic 9
Setting Data Types on the Combined Table
This chapter assumes you can open the Power Query editor, you have a working combined-folder query (see the earlier chapters on Combine & Transform Data), and you know the basic differences between text, number, and date values in Excel.
Why types matter
Power Query assigns each column a data type: text, whole number, decimal number, date, and so on. The type decides how values sort, how they aggregate, and how they behave once loaded to Excel. A column of dates typed as text sorts alphabetically and cannot be grouped by month. A column of amounts typed as text cannot be summed in a PivotTable.
When you combine files, the type step can get lost or applied at the wrong point. That is why you should check the types on the final combined table.
How types arrive in a combined query
CSV files carry no type information. Every value in a CSV is text until something converts it. When Power Query opens a CSV, it often adds a "Changed Type" step that guesses types from the first rows. The guess is made per file, on the sample file, and it can be wrong for other files.
Power Query's type detection has one more rule worth knowing. In the combined query, the generated function applies the sample file's transformations to every file. If the sample file's guessed type is right, the type step works for all files. If one file holds a value that cannot convert, such as N/A in a number column, that cell shows Error after the conversion.
Setting types on the combined table
The most reliable approach is to set types in the final query, after the files are combined. Follow these steps:
- In the Power Query editor, select the combined query (the one that holds your results, not the helper queries).
- Select a column header. On the Transform tab, choose Data Type, then pick the type. Repeat for each column.
- Check the Applied Steps pane. Each change adds or updates a Changed Type step.
Use the icon at the left of each column header to see the current type. ABC means text, 123 means whole number, 1.2 means decimal, and the calendar icon means date.
Choose the type to match the data:
| Data | Type to choose |
|---|---|
| Product codes such as `00417` | Text, so leading zeros survive |
| Counts | Whole Number |
| Prices and amounts | Decimal Number, or Fixed decimal number for currency |
| Order dates | Date |
| Timestamps | Date/Time |
Dates and locale
A value like 03/04/2026 is 3 April in some regions and 4 March in others. If your files use a different date format from your computer's settings, use Data Type > Using Locale. Choose the type (Date) and the locale that matches the files, for example English (United Kingdom). The step then reads the text with that region's rules.
A type step in M
The step you create is a call to Table.TransformColumnTypes. You can see it in the formula bar or in the Advanced Editor:
Typed = Table.TransformColumnTypes(Expanded, {{"Date", type date}, {"Region", type text}, {"Amount", type number}})To parse with a locale, add a third argument:
Typed = Table.TransformColumnTypes(Expanded, {{"Date", type date}}, "en-GB")Checking for errors
After you set types, look for cells that show Error. Select the column and check the quality bar under the header, which shows the share of valid, error, and empty values. To see the cause, click the cell next to the word Error. To fix it, either clean the source value or add a Replace Errors step.
Exercise
A combined query loads a column of product codes such as 00417 and 10388. After loading, Excel shows 417 and 10388. What went wrong, and how do you fix it?
Show answer
The column was typed as Whole Number, which drops the leading zeros. Change the column's type to Text in the combined query, then refresh. If an earlier Changed Type step already converted it, change that step or add a later step that sets Text. The zeros may not return if they were already removed, so set Text before conversion.
Exercise
Your Date column shows no errors, but March and April appear swapped for files exported in the UK. What do you use to correct it?
Show answer
Use Data Type > Using Locale, choose Date, and select English (United Kingdom). This reads the day and month in the order the files use.