Forum Discussion
Carminol
Jan 03, 2022Copper Contributor
Power Query - automatically change type of data inside the column (columns have changing titles)
Dear All, I am trying to develop file that will import data from another Excel file. The table that will be imported is similar to table from below. The problem that I have is how to make my q...
- Jan 03, 2022
To change #1 and #3 on text and rest on whole number
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], columnNames = Table.ColumnNames( Source ), changeType = Table.TransformColumnTypes( Source, List.Transform( columnNames, each if List.PositionOf(columnNames, _) = 0 or List.PositionOf(columnNames, _) = 2 then {_, type text} else {_, Int64.Type} ) ) in changeTypeNames of columns and their number don't matter.
SergeiBaklan
Jan 03, 2022Diamond Contributor
To change #1 and #3 on text and rest on whole number
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
columnNames = Table.ColumnNames( Source ),
changeType = Table.TransformColumnTypes(
Source,
List.Transform(
columnNames,
each
if List.PositionOf(columnNames, _) = 0 or
List.PositionOf(columnNames, _) = 2
then {_, type text}
else {_, Int64.Type}
)
)
in
changeType
Names of columns and their number don't matter.
- CarminolJan 04, 2022Copper ContributorThank you, it works perfectly 🙂
- SergeiBaklanJan 04, 2022Diamond Contributor
Carminol , you are welcome