Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Create a Dynamic Column Based On Other Column Values

Hi Team,   We have a requirement wherein we need to create a new column using existing 3 columns from the same table. Input Table- DataSource Indication SKU DataSource_Mapping Attributes ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

    Please apply the below codes for the main table in Power Query Editor and check if it can return your expected result...

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUYoAYkOlWJ1oJScgC4iMwRxnICsSJBAbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DataSource = _t, Indication = _t, SKU = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"DataSource", type text}, {"Indication", type text}, {"SKU", Int64.Type}}),
        #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type", {"Indication", "SKU"}, "Attribute", "Value"),
        #"Filtered Rows" = Table.SelectRows(#"Unpivoted Only Selected Columns", each ([Value] <> ""))
    in
        #"Filtered Rows"

    Best Regards