Forum Discussion

Savino's avatar
Savino
Frequent Visitor
2 years ago
Solved

= Table.NestedJoin

Hi all, I'm trying to write a formula to process the below list of files Query using Table.Nestedjoin Function (JoinKind.RightAnti).  Table.Nestedjoin Function requires two tables: in my case the f...
  • spinfuzer's avatar
    spinfuzer
    2 years ago

    It sounds like all your want to do is take the max week for each Order and then call it a closed service order on the max week.  

     

    Just Group By Order, Operation Max Week, Operation All Rows.  Expand and add custom column Week = Max Week.

     

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTJUitWJVnKCs0BiRnAxI7iYMVwMwTIBs5yBLFM4y0wpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Order = _t, Week = _t]),
        #"Grouped Rows" = Table.Group(Source, {"Order"}, {{"Max Week", each List.Max([Week]), type nullable text}, {"Rows", each _, type table [Order=nullable text, Week=nullable text]}}),
        #"Removed Columns" = Table.RemoveColumns(#"Grouped Rows",{"Order"}),
        #"Expanded Rows" = Table.ExpandTableColumn(#"Removed Columns", "Rows", {"Order", "Week"}, {"Order", "Week"}),
        #"Added Custom" = Table.AddColumn(#"Expanded Rows", "Closed", each [Week] = [Max Week])
    in
        #"Added Custom"

     

     

    Copy and paste entire code into blank query to see a full example.