Forum Discussion
= Table.NestedJoin
- 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.
Finally I see the light!!! Many Thanks!!!!
Now I need to figure out:
1) how to exclude the last week data since data are inconsistent because they have not a matching week yet;
2) MAX Week doesn't work for the new year. I mean after week 52 (2023) there's week 01 (2024) . I tried to put MAX on Source.Name that is (as example) 2023-W-52 but it doesn't work.
I need to think of it.
Thanks again for your help. I coundn't never achieve this result without your help.
Savino
Probably just concatenate year with week number. 202401 > 202352