Forum Discussion
Recoba88
8 years agoHelper III
Change columns name
Hi, When I try to get data through power query (from google sheets or excel file) I get it by columns - and then ther is automatically change type activated (for example column with title "1"...
- 8 years ago
Remove the #"Changed Type" step.
If you still need to type your data, then there are various ways to do it dynamically, depending on your specific situation and requirements.
MarcelBeug
8 years agoCommunity Champion
A typical example is to create a list with column names and the required types (this is actually a list of lists) and use that as second argument to function Table.TransformColumnTypes.
In this example, Table1 has 3 columns with a whole number, text and date. The query will still run if column names are adjusted.
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
ColumnNames = Table.ColumnNames(Source),
ColumnTypes = {Int64.Type, type text, type date},
TransformSpecs = List.Zip({ColumnNames,ColumnTypes}),
#"Changed Type" = Table.TransformColumnTypes(Source,TransformSpecs)
in
#"Changed Type"
In the "hard coded" version you can also recognize the list of lists as second argument:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Text", type text}, {"Date", type date}})
in
#"Changed Type"
Recoba88
8 years agoHelper III
Awesome
Thanks!