Forum Discussion
Table Transformation
- 1 year ago
Hi, to put the dates on the columns and determine the part in thefirst column, copy thefollowing formula and past it into your advance editor
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Vcy7DcAwCEXRXagtGTA/T+ABolQW+68RYqVJe67e2xtoqRnxIGggnbQzMkK2KpdoTC+nn/sdYipYwftxOs5LZVq8R/ENBmQ+", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Part #" = _t, #"Qual Date" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Part #", type text}, {"Qual Date", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each 1), #"Pivoted Column" = Table.Pivot(#"Added Custom", List.Distinct(#"Added Custom"[#"Qual Date"]), "Qual Date", "Custom", List.Sum) in #"Pivoted Column" - 1 year ago
Hi jvs5899 Could you try this please
let QualTable = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Vcy7DcAwCEXRXagtGTA/T+ABolQW+68RYqVJe67e2xtoqRnxIGggnbQzMkK2KpdoTC+nn/sdYipYwftxOs5LZVq8R/ENBmQ+", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Part #" = _t, #"Qual Date" = _t]), QualChangedType = Table.TransformColumnTypes(QualTable,{{"Part #", type text}, {"Qual Date", type date}}), RecTable = Excel.CurrentWorkbook(){[Name="ReceiptTable"]}[Content], RecChangedType = Table.TransformColumnTypes(RecTable,{{"Part #", type text}, {"Rec. Date", type date}}), MergedTable = Table.NestedJoin(RecChangedType, "Part #", QualChangedType, "Part #", "Qualification", JoinKind.LeftOuter), ExpandedTable = Table.ExpandTableColumn(MergedTable, "Qualification", {"Qual Date"}), FilteredTable = Table.SelectRows(ExpandedTable, each [Rec. Date] >= [Qual Date]), GroupedTable = Table.Group(FilteredTable, {"Part #"}, { {"Data", each Table.Sort(_, {{"Rec. Date", Order.Ascending}})} }), // Step 6: Add Gap Days Column for Consecutive Shipments AddGapColumn = Table.TransformColumns(GroupedTable, { {"Data", each Table.AddColumn(_, "Gap Days", (row) => if Table.RowCount(_) = 1 then null else let CurrentIndex = Table.PositionOf(_, row), PreviousDate = if CurrentIndex > 0 then _[Rec. Date]{CurrentIndex - 1} else null in if PreviousDate = null then null else Duration.Days(row[Rec. Date] - PreviousDate)) )} }), FlattenedTable = Table.ExpandTableColumn(AddGapColumn, "Data", {"Part #", "Rec. Date", "Qual Date", "Gap Days"}), AddRequalificationFlag = Table.AddColumn(FlattenedTable, "Requires Requalification", each if [Gap Days] <> null and [Gap Days] > 730 then "Yes" else "No") in AddRequalificationFlag
Hi jvs5899 ,
we wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.
If our response has addressed by Akash_Varuna Omid_Motamedise your query, please accept it as a solution so that other community members can find it easily.
Thank you.
Hi jvs5899 ,
we wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.
If our response has addressed by @Akash_Varuna @Omid_Motamedise your query, please accept it as a solution so that other community members can find it easily.