Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Changes in column name affecting subsequent Power Query steps

Hi guys, 

 

i have a recurring problem. I have a table in Power Query and a lot of transformations on that table. 

 

Now sometimes it happens that a column name changes in the original table or that i need to change a column name for better understanding. 

 

Now all subsequent steps where the column name is refferred to have to be updated for the new name. Is there an efficient way to do it for alle subsqeuent steps at once?

 

Thanks guys

  • Hello Anonymous 

     

    you can copy paste the code into some editor and replacing your column-references at once.

     

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy

3 Replies

  • Jimmy801's avatar
    Jimmy801
    Community Champion

    Hello Anonymous 

     

    you can copy paste the code into some editor and replacing your column-references at once.

     

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy

  • In such scenerios you can create a view in database and use the view in Power Query. So whenever the changes in table , you can change the names in View. If the Power bi desktop you need to new name then at the end of power query step you can rename.

     

    This is how we managed in some projects.

     

     

    If you donot have control on database, write sql query to extract data from table so that use alias name.

  • CNENFRNL's avatar
    CNENFRNL
    Community Champion

    Anonymous , I'm afraid you have to manually change those hard-coded column names one by one; but a more generic reference to the name of a certain column,

    Table.ColumnNames(#"Some Step"){1}

    renders your M code more flexible; so when you change a column's name next time, you don't need to adjust the M code again.