Forum Discussion
Create list of remaining processes
- 5 years ago
Hello paumac_tubing
try this code.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyTkxKVtJRMjAwApLJpSVKsToowoZAMqk0LQ1d3ARI5iYWZaOLGwPJ4ozMArC4hblZRWUVhvFIwijGI4mjGI8kjjA+FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"part #" = _t, step = _t, #"step description" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"part #", type text}, {"step", type text}, {"step description", type text}}), Sort = Table.Buffer(Table.Sort(#"Changed Type",{{"part #", Order.Ascending}, {"step", Order.Ascending}})), Grouped = Table.Group(Sort, {"part #"}, {{"group", each _, type table [#"part #"=nullable text, step=nullable number, step description=nullable text]}}), AddList = Table.TransformColumns ( Grouped, { { "group", (tableint)=> let AddIndex = Table.AddIndexColumn(tableint,"Index",0), AddList = Table.AddColumn ( AddIndex, "Subsequent", (add) => try Text.Combine(List.Range(AddIndex[step description], add[Index]+1), ", ") otherwise "" ) in AddList } } ), Expand = Table.ExpandTableColumn(AddList, "group", {"step", "step description", "Subsequent"}, {"step", "step description", "Subsequent"}) in ExpandBut i realized just now that somebody else was working on the similar approach in the same time 🙂
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
hi, I think I've solved your issues as follows with the help of index column:
let
Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Part", type text}, {"Step", type text}, {"Step description", type text}}),
#"Sorted Rows" = Table.Sort(#"Changed Type",{{"Part", Order.Ascending}, {"Step", Order.Ascending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1),
AddRemaingStep = Table.AddColumn(#"Added Index","RemainingSteps",each Text.Combine(
List.Range(#"Added Index"[Step description],[Index]+1,
List.Max(List.PositionOf(#"Added Index"[Part],[Part],Occurrence.All))-[Index]),
","
)),
#"Removed Columns" = Table.RemoveColumns(AddRemaingStep,{"Index"})
in
#"Removed Columns"