Forum Discussion

T-Pan's avatar
T-Pan
Icon for Helper I rankHelper I
2 years ago
Solved

Get data from folder issue.

Hello everyone, on my job i have to create a report which will be updated daily with the excels in picture below. As you will see, all columns of these excels have the same Column names except the second column. So if i want to choose to get data from folder it works perfectly for all columns except the second which only returns the values of the excel wich i use as sample. I could also upload every day the excel and append the columns with same name and merged the columns with different names into a new column, but what i am looking for is a more automated procedure through power query and not a daily manual append. Does anyone know a way to solve this?

 

 

  

 

 

 

 

  • spinfuzer m_dekorte , in tranform sample query, i deleted the promote to headers step and add another step of "delete the first row". So now i have column 1, column 2, etc,  as headers and in my appended query  renamed the columns as i want. I don't know if its the right way but it works.

11 Replies

  • spinfuzer m_dekorte , in tranform sample query, i deleted the promote to headers step and add another step of "delete the first row". So now i have column 1, column 2, etc,  as headers and in my appended query  renamed the columns as i want. I don't know if its the right way but it works.

    • spinfuzer's avatar
      spinfuzer
      Icon for Solution Sage rankSolution Sage

      That sounds good.  All you need to do is make sure you have the same column names one way or another.

  • Edit the Sample File.

    Demote Headers

    Extract Text After Delimiter Space on the second column

    Promote Headers.  The column name is now just "Missing".

    • T-Pan's avatar
      T-Pan
      Icon for Helper I rankHelper I

      But again its different Column name from the other Excels as you can see from images.  Will ot work?

      • spinfuzer's avatar
        spinfuzer
        Icon for Solution Sage rankSolution Sage

        Is Column2 always "Date Missing"?  Date followed by a space then Missing?  If so, yes, it will work.

         

  • m_dekorte's avatar
    m_dekorte
    Icon for Resident Rockstar rankResident Rockstar

    Alternatively you can transform column names, that will look something like this:

    Table.TransformColumnNames( PrevStepName, each if Text.Contains(_, ".") then Text.AfterDelimiter(_, " ") else _)

     

    And if as you say it is always the second column, you can easily extract that date and add its value to a new column in the table. That will look something like this.

    Table.AddColumn( PrevStepName, "Date", each Text.BeforeDelimiter( Table.ColumnNames(PrevStepName){1}, " ")) 

    • T-Pan's avatar
      T-Pan
      Icon for Helper I rankHelper I

      I do this after i have combined the excels in power query?(get data from folder / combine and tranform) 

      • m_dekorte's avatar
        m_dekorte
        Icon for Resident Rockstar rankResident Rockstar

        No, you would add that to the Transform Sample Query. If you share the code that's in that Transform Sample Query, we can help incorporate that rename step and optionally the add column step as well if desired.