Table.TransformColumnTypes

Table

Transforms the types of the specified columns in a table.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Table.TransformColumnTypes(table as table, typeTransformations as list, optional culture as nullable text) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe input table whose column types are to be transformed.
typeTransformationslistYesA list of column name and type pairs, each specified as {columnName, newType}.
culturetextNoOptional culture string used for locale-sensitive type conversions (e.g., "en-US").

Return Value

tableThe 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}})
Result
OrderID
CustomerName
Product
Category
UnitPrice
Quantity
OrderDate
Region
11AliceWidget AWidgets2541/15/2024East
22BobGadget BGadgets5021/18/2024West
33CharlieWidget CWidgets15102/1/2024East
44AliceGadget DGadgets7512/10/2024North
55DianaWidget AWidgets2563/5/2024West

Example 2: Change multiple column types at once

Table.TransformColumnTypes(Sales, {{"UnitPrice", type text}, {"Quantity", type text}})
Result
OrderID
CustomerName
Product
Category
UnitPrice
Quantity
OrderDate
Region
11AliceWidget AWidgets2541/15/2024East
22BobGadget BGadgets5021/18/2024West
33CharlieWidget CWidgets15102/1/2024East
44AliceGadget DGadgets7512/10/2024North
55DianaWidget AWidgets2563/5/2024West

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks