Forum Discussion
replace row value in nested table based on condition in power query
Hope my question understandable.
Thanks you in advance!
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
6 Replies
- AlienSxSuper User
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 - Mahesh0016Super User
let
Source = #"Table Phase",
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
expandAnonymous I hope this helps you!Thank You!!
- AnonymousNot applicable
Hello,
I found that this solution giving complete table row info but I wanted the info as below:
I dont wanted crossed info inside nested table, any other solution for it?
Thank you in advance
- AlienSxSuper User
Anonymous I don't see you are grouping by Material at all while my code groups data by Material and then applies some logic to get new flag. Show your code please.
- AnonymousNot applicable
This is the code
let
Source = #"Changed Type",
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)