Forum Discussion

G_Whit-UK's avatar
G_Whit-UK
Helper II
2 years ago
Solved

Create column in table if it doesn't exist

Hi   I'm working within Power Query to analyse a system output file which lists reconciliation items between two systems.  When the recon doesn't have any exceptions, the output file is simply the ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi G_Whit-UK ,

    List all the required columns in advance and refer to the steps below:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkpNzi9KUTBU0lEKzi8tSk5VCK4sLknNVTBUCEvMKU0FihsqxerAFRrhUWiErNAYn4l65kqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Record ID" = _t, Attribute = _t, Value = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", Int64.Type}}),
        #"Source System List" = {"Source System 1 Value","Source System 2 Value"},
        Custom1 = Table.Group(#"Changed Type",{"Record ID"}, List.Transform(#"Source System List", (y) => { y, (x) => try Table.SelectRows(x, each [Attribute] = y)[Value]{0} otherwise null }))
    in
        Custom1

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group