Forum Discussion

polman4's avatar
polman4
Helper I
4 years ago

Merge 3 tables (Append?)

Hello,

 

I have 3 different tables that I would like to merge into one. Actually from what I understand i need to do an append query but everything I tried is not working fine.

 

Below you find the structure from the 3 tables.

 

TimeSitePageFormatInsertionInsertion TypeImpressionsInventoryViewable ImpressionsRevenueTable
TimeName (Site)Name (Page)Name (Format)Name (Insertion)Name (Insertion Type)ImpressionsTotal inventoryViewable impressions Table1
TimeName (Site)Name (Page)Name (Format)Name (Insertion)Name (Insertion Type)RTB+ Impressions Viewable impressionsRTB+ Gross revenueTable2
TimeName (Site)Name (Page)Name (Format)  HB Impressions  HB RevenueTable3

 

I don't want to merge columns just need to append data from each column into the new merging table but each column needs to be appended to the right column. Some columns may be left empty.

 

The last column will be written depending the table. For example if this rows data belong to "table1" then write table 1, etc

 

Any suggestion?

 

Thank you,

Greg

3 Replies

  • KNP's avatar
    KNP
    Super User

    Hi Greg,

     

    Have a look at the attached PBIX.

    The way I would typically deal with this is to skip the headers, append, add desired headers back on.

    As for a column for the source table, add that prior to appending. Doing this dynamically will depend on the data source. May need some more info to assist with that, but let's start with the append.

     

     

  • Hello KNP,

     

    Thank you a lot for the reply and the example!

     

    What troubles me is that the 3 tables i have don't have the same structure. For example table 2 is missing Inventory Column. From what i've seen you are using as base "storeA" table at your example with 

    = Table.ColumnNames(StoreA)

     

    So (i guess) i can't just append the 2nd and 3rd table to first since the structure isn't the same. Maybe a 1 to 1 matching is needed?

     

    Thank you,

    Grigoris

  • KNP's avatar
    KNP
    Super User

    Sorry, I just reread your post, I understand the column structure better now.

     

    I think what you actually need to do is rename the columns of each of the three tables prior to the append. 

    If each of the three files you have are at least consistent (individually) you could just do the rename on the three files and then append.