Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
casamontagna
Frequent Visitor

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.

1 ACCEPTED SOLUTION

Hello @casamontagna ,

 

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

View solution in original post

3 REPLIES 3
casamontagna
Frequent Visitor

2020-01-10 15_35_06-Unbenannt - Power Query-Editor.jpg

Hello @casamontagna ,

 

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

thank you so much, made my day!!!

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.