Forum Discussion

TobyC84's avatar
TobyC84
Copper Contributor
Sep 16, 2021
Solved

Power Query Replace Data Help Please (Tiime Sensitive)

Hey everyone! Here is my conundrum. I have a workbook with several columns and rows. I have a column for product SKUs and a column for Price, as well as a bunch of other info in "workbook A". I need ...
  • SergeiBaklan's avatar
    Sep 16, 2021

    TobyC84 

    Assuming SKU are unique in both tables, you may merge A with B, add custom column for corrected price (if null then oldPrice else newPrice) and do cosmetic

    For such sample

    generated script is

    let
        Source = Table.NestedJoin(
            TableA, {"SKU"},
            Table2, {"SKU"},
            "Table2", JoinKind.LeftOuter
        ),
        #"Expanded Table2" = Table.ExpandTableColumn(
            Source,
            "Table2",
            {"Price"}, {"Price.1"}
        ),
        #"Added Custom" = Table.AddColumn(
            #"Expanded Table2",
            "Price Corrected",
            each
                if [Price.1] = null 
                then [Price] 
                else [Price.1]),
        #"Removed Other Columns" = Table.SelectColumns(
            #"Added Custom",
            {"SKU", "Price Corrected", "V"}
        )
    in
        #"Removed Other Columns"

Resources