Forum Discussion

paumac_tubing's avatar
paumac_tubing
Regular Visitor
5 years ago
Solved

Create list of remaining processes

So I have been working on a project that has me stumped   What i am looking to do is create a concatinated list of steps remaining. My data looks like this part #        step         step descript...
  • Jimmy801's avatar
    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
        Expand

    But 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