Forum Discussion

magloons's avatar
magloons
Regular Visitor
1 year ago
Solved

Merge two tables with no usable identifiers

The problem: I have two tables. One only contains the Truck ID and each Article on the truck and the other table contains only the delivery date and the article number expected to be delivered on tha...
  • ronrsnfld's avatar
    ronrsnfld
    1 year ago

    For some reason, you have chosen to not show what you expect for results from the data you have presented.

     

    However, examination of your data shows that the articles are listed in exactly the same order in both tables. If that is truly the case and relevant, all you need to do is add the Delivery_Date column to your Table A. (If that is not the case, you will need to provide what I previously requested along with your logic in developing your result table)

     

    let
    
    //Read in the data tables
        SourceA = Excel.CurrentWorkbook(){[Name="TableA"]}[Content],
        TableA = Table.TransformColumnTypes(SourceA,{{"Truck_ID", type text}, {"Article_Number", Int64.Type}}),
        SourceB = Excel.CurrentWorkbook(){[Name="TableB"]}[Content],
        TableB = Table.TransformColumnTypes(SourceB,{{"Delivery_Date", type date}, {"Article_Number", Int64.Type}}),
    
    //Add the delivery date column
        #"Add Delivery Date" = 
            Table.FromColumns(
                Table.ToColumns(TableA) &
                {TableB[Delivery_Date]},
                type table[Truck_ID=text, Article_Number=Int64.Type, Delivery_Date=date])
    in
        #"Add Delivery Date"