Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

replace row value in nested table based on condition in power query

Could anyone suggest for below query please?    I have source columns Material, Plant and Flag Status · Required to build new column in power query nested table · Logic: o If Group of material b...
  • AlienSx's avatar
    3 years ago
    let
        // replace your_table with correct reference to your original data
        Source = your_table,
        f = (tbl as table) as table =>
            [a = List.Contains(tbl[Flag Status], "No Phase out"),
            b = Table.AddColumn(tbl, "new flag", (x) => if (Text.Start(x[Plnt], 1) = "A"  and a) then "No Phase out" else x[Flag Status])][b],
        gr = Table.Group(Source, "Material", {{"all", each f(_)}}),
        expand = Table.ExpandTableColumn(gr, "all", {"Plnt", "Flag Status", "new flag"})
    in
        expand