Forum Discussion

AndrewDavies437's avatar
4 years ago

Excel data-source headings keep changing every month.

I'm looking for a solution to an issue i'm having with a client. 

I have made them a power BI dashboard which works. Each month the client would like to update the datasource with a new excel file containing the same data as the previous excel file. However, quite often the column headers of the datasource change. This of course, causes issues with the dashboard when the new data source is uploaded.

 

For example:

"Total Income" changes to become "Total income (CT)"

or

"Commission Fee" changes to become "Commission Fee (AZ)".

 

Changes like this occur almost every month.

 

They do not have control of their datasource as it is exported from a third party software (which changes the column headers regularly).

 

This makes reporting quite difficult. 

 

However, the order of the columns remains the same. I was hoping I could replace the column headers with A B C D E F G etc and then change them in a later step to work around this issue. 

 

Is this possible in Power Query?

 

Any help would be greatly appreciated.

 

Thank you.

 

 

 

3 Replies

  • AndrewDavies437 yes it possible, add the following steps to rename the columns, 

     

    Old Column Name steps - gets the existing columns name of the table from the previous step

    New Column Name steps - a list of column names you want to be, make sure these column names are in the correct order.

    Rename column steps renames the old columns with the new columns. 

     

    With this solution it doesn't matter what is the column name in the excel file, as far as number of columns are the same, it should work.

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0MjAAUgpKsTrRSkZAlhFEwMJYFSxkDGRbgkV0TS2BQrEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CINESEMANA = _t, PÚBLICO = _t, #"VAR%" = _t]),
        #"Old Column Names" = Table.ColumnNames(Source),
        #"New Column Names" = { "Test1", "Test2", "Test3"},
        #"Rename Columns" = Table.RenameColumns(Source,List.Zip({#"Old Column Names",#"New Column Names"}))
    in
        #"Rename Columns"

     

     

    Follow us on LinkedIn and  to our YouTube channel

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    • AndrewDavies437's avatar
      AndrewDavies437
      Helper I

      Thank you for the reply!  

       

      I have tried another method that seems simpler, but would like to know if this is going to cause any issues because it seemed too easy. 

       

      I just deleted the "promoted headers" step and renamed my columns to what they'd want to be, then removed the first row (the headers).

       

      Will this run into issues down the line?

       

      If it does I will use your method but is there any reasons we aren't just doing it like this?

       

      Thanks so much for your time. 

  • AndrewDavies437 it should work fine as well.

     

    Follow us on LinkedIn and  to our YouTube channel

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!