Forum Discussion
jaryszek
1 year agoSuper User
Importing table with predefined data type from metadata
Hi Guys, I do not want Power Query to automatically detect data changes. If it is possible to read column data types from medata table like: Table1, Column1, String Table1, Column2, Integer ...
- 1 year ago
Solution code:
let types = [Text = Text.From, #"Decimal number" = Number.From, #"Whole number" = Int64.From], type_table = Table.Group( Excel.CurrentWorkbook(){[Name="ColumnDataTypes"]}[Content], "TableName", { "transform", (x) => List.Zip( { x[ColumnName], List.Transform(x[ColumnDataType], (w) => Record.FieldOrDefault(types, w, each _)) } ) } ), type_record = Function.Invoke(Record.FromList, List.Reverse(Table.ToColumns(type_table))), result = ((table_name) => Table.TransformColumns( Record.Field(#shared, table_name), Record.Field(type_record, table_name), null, MissingField.Ignore )) ("PetTable") in resultapproach taken from https://www.excelforum.com/office-365/1433993-power-query-to-import-column-data-types-from-table.html
Best,
Jacek
jgeddes
1 year agoSuper User
It will depend on the source of your data.
Please see the attached support document.
https://support.microsoft.com/en-us/office/add-or-change-data-types-power-query
jaryszek
1 year agoSuper User
Thanks but i do not want to make power query detecs data types from my source.
I need to have a table with metadata and apply it for each power query to read data types.
How to make a power query to achive it?
Best,
Jacek