Table.TransformColumnTypes
TableTransforms the types of the specified columns in a table.
Syntax
Table.TransformColumnTypes(table as table, typeTransformations as list, optional culture as nullable text) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
table | table | Yes | The input table whose column types are to be transformed. |
typeTransformations | list | Yes | A list of column name and type pairs, each specified as {columnName, newType}. |
culture | text | No | Optional culture string used for locale-sensitive type conversions (e.g., "en-US"). |
Return Value
table — The input table with the specified columns converted to the given types.
Remarks
Table.TransformColumnTypes changes the data type of one or more columns. The typeTransformations parameter is a list of lists, where each inner list contains the column name and the target type (e.g., {{"OrderID", type text}}).
If a value cannot be converted to the target type, it results in an error for that cell. Use the optional culture parameter to control locale-specific formatting during conversion.
If you have multiple "Changed Type" steps in your query, consolidate them into a single Table.TransformColumnTypes call. Multiple separate type-change steps add unnecessary overhead and make the query harder to maintain.
When working with a database source (SQL Server, Oracle, etc.), be aware that Table.TransformColumnTypes can break query folding. If the type change happens after a foldable step, the engine may pull all data locally before applying the conversion. In database scenarios, prefer handling type conversions in the source query or use Table.TransformColumns with a conversion function instead.
Examples
Example 1: Change a single column type
Table.TransformColumnTypes(Sales, {{"OrderID", type text}})OrderID | CustomerName | Product | Category | UnitPrice | Quantity | OrderDate | Region | |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | Alice | Widget A | Widgets | 25 | 4 | 1/15/2024 | East |
| 2 | 2 | Bob | Gadget B | Gadgets | 50 | 2 | 1/18/2024 | West |
| 3 | 3 | Charlie | Widget C | Widgets | 15 | 10 | 2/1/2024 | East |
| 4 | 4 | Alice | Gadget D | Gadgets | 75 | 1 | 2/10/2024 | North |
| 5 | 5 | Diana | Widget A | Widgets | 25 | 6 | 3/5/2024 | West |
Example 2: Change multiple column types at once
Table.TransformColumnTypes(Sales, {{"UnitPrice", type text}, {"Quantity", type text}})OrderID | CustomerName | Product | Category | UnitPrice | Quantity | OrderDate | Region | |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | Alice | Widget A | Widgets | 25 | 4 | 1/15/2024 | East |
| 2 | 2 | Bob | Gadget B | Gadgets | 50 | 2 | 1/18/2024 | West |
| 3 | 3 | Charlie | Widget C | Widgets | 15 | 10 | 2/1/2024 | East |
| 4 | 4 | Alice | Gadget D | Gadgets | 75 | 1 | 2/10/2024 | North |
| 5 | 5 | Diana | Widget A | Widgets | 25 | 6 | 3/5/2024 | West |