Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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...
  • Jimmy801's avatar
    Jimmy801
    6 years ago

    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
    	Group

    Copy 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