Forum Discussion
extract minimum and maximum in a category?
Dears,
i need to extract the first and last date of postings on projects, i only need this information. I grouped by projects and date, and now i'd like to delete all dates between first and last posting. in case there is only 1 posting on a project, this posting should remain as first and last.
the desired result are that the blue outlined lines remain. i thought already about creating a tabel for max values and a second one for minimum values of the date. but i don't get the clue how to check if the project in one line is the same or different to the project in the next line.
Hello Anonymous ,
Use Table.Group for this and select Min and Max for the Date-column .
Here a code example
let Source = #table ( {"Project","Date"}, { {"A","43466"}, {"A","43467"}, {"A","43468"}, {"A","43469"}, {"B","43470"}, {"B","43471"}, {"B","43472"}, {"B","43473"}, {"B","43474"}, {"C","43475"}, {"C","43476"}, {"C","43477"}, {"C","43478"} } ), ToDate = Table.TransformColumns ( Source, { { "Date", each Date.From(Number.From(_)), type date } } ), Group = Table.Group(ToDate, {"Project"}, {{"Min", each List.Min([Date]), type date}, {"Max", each List.Max([Date]), type date}}) in GroupCopy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
3 Replies
- AnonymousNot applicable
- Jimmy801
Community Champion
Hello Anonymous ,
Use Table.Group for this and select Min and Max for the Date-column .
Here a code example
let Source = #table ( {"Project","Date"}, { {"A","43466"}, {"A","43467"}, {"A","43468"}, {"A","43469"}, {"B","43470"}, {"B","43471"}, {"B","43472"}, {"B","43473"}, {"B","43474"}, {"C","43475"}, {"C","43476"}, {"C","43477"}, {"C","43478"} } ), ToDate = Table.TransformColumns ( Source, { { "Date", each Date.From(Number.From(_)), type date } } ), Group = Table.Group(ToDate, {"Project"}, {{"Min", each List.Min([Date]), type date}, {"Max", each List.Max([Date]), type date}}) in GroupCopy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy- AnonymousNot applicable
thank you so much, made my day!!!