Hi Mr. Excel Nation!
I have been trying to extract a single date (Min) or the earliest date and the latest date (Max) from a grouped list using Power Query.
I have only posted a snip of the data and taken out confidential columns. But the original dataset is 15K rows of product materials along with their availability on the market dates.
Any help you can provide will be appreciated!
Thank you for your help!
I have been trying to extract a single date (Min) or the earliest date and the latest date (Max) from a grouped list using Power Query.
I have only posted a snip of the data and taken out confidential columns. But the original dataset is 15K rows of product materials along with their availability on the market dates.
Power Query:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type1" = Table.TransformColumnTypes(Source,{{"Matl No", type text}, {"Matl Desc", type text}}),
#"Changed Type" = Table.TransformColumnTypes(#"Changed Type1",{{"Matl No", type text}, {"Matl Desc", type text}, {"Market Date", type datetime}, {"DeMarket Date", type datetime}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Matl Desc", "Matl No"}, {{"All Data", each _, type table [Matl No=nullable number, Matl Desc=nullable text, Market Date=nullable datetime, DeMarket Date=nullable datetime]}}),
#"Reordered Columns" = Table.ReorderColumns(#"Grouped Rows",{"Matl No", "Matl Desc", "All Data"}),
#"Add to List" = Table.AddColumn(#"Reordered Columns","Market Date", each [All Data][Market Date]),
#"Addition to List" = Table.AddColumn(#"Add to List","DeMarket Date", each [All Data][DeMarket Date]),
#"Extract From List" = Table.TransformColumns( #"Addition to List", {"Market Date", each Text.Combine(List.Min(List.Transform(_, Text.From)), "#(lf)"), type text})
in
#"Extract From List"
Any help you can provide will be appreciated!
Thank you for your help!