Forum Discussion

sivarajan21's avatar
sivarajan21
Icon for Post Prodigy rankPost Prodigy
2 years ago
Solved

Power query transformations to lookup dates from one table into the other

Hi,   I have invoice detail table as below which has a date column:   Also, I have EM - Misc Charge table that don't have date column:   But these 2 tables have 'DBName-Point_Id' , ...
  • jgeddes's avatar
    jgeddes
    2 years ago

    You can do that. 

    For instance, if you wanted to add your EM - Misc Charge table (with dates) to the Invoice Detail table you could add this step to the Invoice Detail query.

    combineTables = 
        Table.Combine(
            {
                #"Changed Type",
                Table.ExpandTableColumn(
                    Table.NestedJoin(
                        #"EM - Misc Charge", 
                        {"DBName-Point_Id", "DBName-Id", "Charge"}, 
                        #"Changed Type", 
                        {"DBName-Point_Id", "DBName-Id", "Charge"}, 
                        "Invoice Detail", 
                        JoinKind.LeftOuter
                    ), 
                    "Invoice Detail", 
                    {"Date"}, 
                    {"Date"}
                )
            }
        )

     Again I note that this only works correctly if you have an unique key to build the join with. 
    In the dummy set for an example if you look at 

    There are four rows that are not unique. So they end up joining with 245 rows in the Invoice Detail table that are 'EMSQL_BWS-33524, EMSQL_BWS-159176, Standing_Charge'.

    Hope this gets you pointed in the right direction.

    Cheers.