Forum Discussion

Carminol's avatar
Carminol
Copper Contributor
Jan 03, 2022
Solved

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...
  • SergeiBaklan's avatar
    Jan 03, 2022

    Carminol 

    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.

Resources