Forum Discussion

davox01's avatar
davox01
Regular Visitor
4 years ago
Solved

Referencing a column by position not name as name is variable

I'm new to power query and have query running that combines all files in folder, but it errors if i don't include the initial file.   It takes all the files from within a folder combines them and t...
  • Vijay_A_Verma's avatar
    4 years ago

    1. Insert an Index column just before #"Promoted Headers".

    2. Issue this statement (This would change your first row to a column name "Source Name"

    Table.ReplaceValue(#"Added Index",each [Source.Name],each if [Index] = 0 then "Source Name" else [Source.Name],Replacer.ReplaceValue,{"Source.Name"})

    3. Now delete the Index column

    4. After this you can promote headers.

  • davox01's avatar
    davox01
    4 years ago

    Thanks I actually used a different solution where i refered to the column by its number  0 = first column.

     

    #"Renamed Columns3" = Table.RenameColumns(#"Changed Type1",{{Table.ColumnNames(#"Changed Type1"){0}, "Source"}}),