In this article I’ll show you how to create types from text in Power Query, enabling you to dynamically change types via functions for example. It’ll come out as a custom Type.FromText function which has been asked for in the comments of this article: https://www.thebiccountant.com/2017/01/09/dynamic-bulk-type-transformation-in-power-query-power-bi-and-m.
Problem
To transform a column to type text can be done like so:
Table.TransformColumnTypes(Source,{{"Column1", type text}})
This transforms the “Column1” from table “Source” to type text. Now, if you want to make the type dynamic and move it to a function parameter like so:
(VariableType as type) => Table.TransformColumnTypes(Source,{{"Column1", VariableType}})
This returns a function dialogue as follows:
