Forum Discussion

Tob_P's avatar
Tob_P
Helper V
2 years ago
Solved

Order sequentially after Table.Buffer

I have the following in PQ...   let Source = #"NAV_Sales Header", #"OTP <> Blank" = Table.SelectRows(Source, each ([OTP No_] <> "")), #"Sorted Created On Desc/added Table.Buffer prefix" = Table....
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Tob_P 

    You can refer to the following code.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hcwxDoAgEETRu2xNAjOyu7H2BCZ2hPtfQwrRGIhWU7z8KUWYmCMiJMhxgEvbbQezmksNH+5p9Fbdrvo4ew90N7MfXydO7e7uoyfwcnWd/L+89fUE", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, No = _t, #"Quote No" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"No", type text}}),
        #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Date", Order.Ascending}, {"No", Order.Ascending}}),
        #"Grouped Rows" = Table.Group(#"Sorted Rows", {"No"}, {{"MaxQuoteNo", each List.Max([Quote No]), type nullable text}, {"Data", each _, type table [Date=nullable date, No=nullable text, Quote No=nullable text]}}),
        #"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"Date", "Quote No"}, {"Date", "Quote No"}),
        #"Filtered Rows" = Table.SelectRows(#"Expanded Data", each [Quote No] =[MaxQuoteNo]),
        #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"MaxQuoteNo"})
    in
        #"Removed Columns"

    Output

     

     

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.