Sub topic 5
Setting data types and locale
This chapter assumes you can open the Power Query Editor, read the Applied Steps pane, and have already promoted headers on a table. It covers how a column's type is set, why locale changes the result, and the errors that come from getting either wrong.
Why types come first
Every column in Power Query has a data type. The type controls how values are sorted, compared, aggregated, and later loaded into the Power BI model. A column of dates stored as text sorts alphabetically, so "10/01/2026" lands before "2/01/2026". A column of numbers stored as text cannot be summed.
Type conversion is also the step where hidden problems become visible. Text that cannot be parsed turns into an error value, so a type change doubles as a test of the data. The later chapters on text cleaning, nulls, and errors build on that.
The common types
The type selector is the icon at the left of each column header. It is also under Transform > Data Type.
| Editor name | M type | Notes |
|---|---|---|
| Whole Number | `Int64.Type` | Integers only. Converting a decimal rounds it. |
| Decimal Number | `type number` | Floating point. Small rounding differences are possible. |
| Fixed Decimal Number | `Currency.Type` | Four decimal places, exact. Suited to money. |
| Percentage | `Percentage.Type` | A number displayed as a percent. |
| Date | `type date` | Date only. |
| Date/Time | `type datetime` | Date and time of day. |
| Date/Time/Timezone | `type datetimezone` | Includes a UTC offset. |
| Time | `type time` | Time of day only. |
| Duration | `type duration` | A length of time. |
| Text | `type text` | Any string. |
| True/False | `type logical` | Boolean. |
| Any | `type any` | No type. Shown as ABC123. |
A column with type Any is untyped. Power BI will not infer a type for it when it loads, and the result can be inconsistent. Treat Any as unfinished work.
Two kinds of "type"
Changing a type is a transformation. It converts every value and is recorded as a step. Power Query also has a looser idea of a type, an ascription. This is a label on the column and does not change the values.
The editor's Change Type uses Table.TransformColumnTypes, which converts values. You will rarely need ascription directly, but it explains why a column's header icon can look correct while the values underneath are still text.
Automatic detection
When you load a CSV or Excel sheet, the editor often adds steps named Promoted Headers and Changed Type without being asked. Power Query samples the first rows of the source and guesses a type for each column. You can control this under File > Options and settings > Options > Data Load > Type Detection, which can be always on, per file, or never.
Detection has two weaknesses:
- It sees only a sample. If row 5,000 holds "N/A" in a numeric column, the guess was made without it. That row becomes an error on refresh.
- It guesses the locale from your machine, which is a problem for shared reports.
For production queries, review the auto-generated Changed Type step and set types yourself.
Locale: why the same text parses differently
Text such as "03/04/2026" is ambiguous. In the US it is March 4. In the UK it is April 3. The decimal marker has the same problem. "1.234" is about one in the US and one thousand two hundred thirty-four in Germany.
A locale (or culture) is a code like en-US or de-DE that tells the parser which conventions to apply. By default, Power Query uses the regional settings of the machine that runs the refresh. This means the same query can give different results on a laptop and on a server, and nothing shows an error.
To set the locale on one step, right-click the column header, choose Change Type > Using Locale, then pick both a type and a locale. The step records the locale as the last argument:
let
Source = #table(
{"OrderDate", "Amount"},
{{"27.11.2026", "1.234,50"}, {"01.12.2026", "99,00"}}
),
Typed = Table.TransformColumnTypes(
Source,
{{"OrderDate", type date}, {"Amount", type number}},
"de-DE"
)
in
TypedThe locale is a property of this step, so the result no longer depends on the machine. Amount becomes 1234.5 and 99.
The same input read with a different locale gives different dates:
let
Source = #table({"OrderDate"}, {{"03/04/2026"}}),
AsUS = Table.TransformColumnTypes(Source, {{"OrderDate", type date}}, "en-US"),
AsGB = Table.TransformColumnTypes(Source, {{"OrderDate", type date}}, "en-GB")
in
[US = AsUS{0}[OrderDate], GB = AsGB{0}[OrderDate]]The record returned shows US = 2026-03-04 and GB = 2026-04-03. Neither is an error. One is simply wrong for your data, so you must know which format the source uses.
Setting a default for the whole file
If every source in a report uses the same conventions, set the locale once. In Power BI Desktop, open File > Options and settings > Options, then under Current File choose Regional Settings. This applies to the file and travels with it. A per-step locale still overrides it.
A sound order of operations
Convert types after you clean the text, not before. A value like " 120 " with a leading space, or "$1,200", will not convert to a number cleanly. Converting first produces errors you then have to chase. Trim, remove symbols, and fix known bad values first.
Common errors and how to read them
- DataFormat.Error: We couldn't convert to Number. The text does not match the locale. Check for "N/A", a thousands separator, or a decimal comma read as a period. Click the error cell to see the offending value in the preview below the grid.
- Silent wrong dates. The conversion succeeded under the wrong locale. Spot-check a date where the day is greater than 12, such as the 27th. If it turned into an error or a swapped value, the locale is wrong.
- Expression.Error: The column 'X' of the table wasn't found.
Table.TransformColumnTypesnames columns explicitly. If the source renames a column, the step fails on refresh. Fix the name in the step. - Rounded values. Converting a decimal column to Whole Number rounds it. Convert to Decimal or Fixed Decimal if you need the fractions.
- Many Changed Type steps. Each manual change adds a step. Combine several columns into one step by selecting them together, or edit the existing step in the formula bar instead of stacking new ones.
Reading the step in the formula bar
The first code example in this tutorial's plan shows the full pattern. The final line of that query passes the locale as a string:
let
Source = Csv.Document(File.Contents("C:\Data\sales.csv"), [Delimiter = ",", Encoding = 65001]),
PromotedHeaders = Table.PromoteHeaders(Source, [PromoteAllScalars = true]),
ChangedType = Table.TransformColumnTypes(
PromotedHeaders,
{{"OrderID", Int64.Type}, {"OrderDate", type date}, {"Amount", type number}},
"en-US"
)
in
ChangedTypeEach inner pair is {column name, type}. The third argument is the culture. If you omit it, the machine's regional settings apply. Adding it is a small edit with a large effect on reliability.
Exercise
A text column holds "05/06/2026" and the source system is in the UK, so the date is 5 June. You change the type to Date on a machine with US regional settings and no locale is set. What do you get, and how do you fix it?
Show answer
The machine reads the text as US format and returns 6 May 2026, with no error. To fix it, use Change Type > Using Locale with Date and English (United Kingdom), or edit the step to pass "en-GB" as the third argument of Table.TransformColumnTypes.
Exercise
A Decimal Number column named Price must match an accounting system exactly to four decimal places. Which type should you choose, and why?
Show answer
Fixed Decimal Number (Currency.Type). It stores values exactly with four decimal places. Decimal Number is floating point and can introduce small rounding differences.