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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
bucket
Frequent Visitor

Get Start (earliest) and End (latest) Dates from a List of Items (projects)

I have a table with project names, a date column, and some other columns.  I am trying to create a query that produces a table with projects and their start and end dates. 

 

Start date defined as the earliest date in a column of dates, for a given project. 

End date defined as latest date in, the same column of dates, for a given project. 

 

My sample data is below.  I couldn't figure out how to attach the file here.  

 

The projects are listed multiple times.  I think I need to copy the query, rename it min date, loop through the list of projects and find the earliest date earliest date.  Do the same for latest date.  I'm stuck on trying to get the dates linked back to a single project.  I don't know how to deal with the duplicate projects.  

 

I found this method but can't get it to account for the duplicate projects.  https://www.myonlinetraininghub.com/extract-start-and-end-dates-with-power-query

 

Trying to get a query that produces something like this:

 

ProjectStart DateEnd Date
   
   

 

Sample data (there are thousands of rows, this is only a subset):

 

ProjectMilestoneResourceDateHoursIndex
Project C Malick, Martin8/3/2020225759
Project A Malick, Martin8/10/2020225760
Project C Blue, Steph8/17/2020225761
Project C Blue, Steph8/24/2020225762
Project B Blue, Steph8/31/2020224433
Project AMilestone 2 9/7/2020212764
Project C Blue, Steph9/21/2020212766
Project C Blue, Steph10/5/2020210768
Project C Fanny, Pack8/31/2020209763
Project BMilestone 1 9/7/2020202434
Project B Fanny, Pack8/17/2020198431
Project A  9/14/2020195765
Project B Malick, Martin8/10/2020192430
Project C Fanny, Pack9/28/2020192767
Project A Field, Sally10/12/2020185769

 

1 ACCEPTED SOLUTION
ziying35
Impactful Individual
Impactful Individual

@bucket 

Power Query:

 

 

// output
let
    Source = Table.FromRecords(Json.Document(Binary.Decompress(Binary.FromText("rZRLa4QwFIX/imQdMInPuKstQ7sQhnZZuwhOoHZCLD6gQ5n/3khfsTHaCe5iCHyec+65j+9g3zYvvOpB9n3yrgEERS141zeSg0wOQkBwz7tmaCv1DQom6uoIvYK1fS3V4xvWj/dp6QelTxBB6u5Wve5ARkgEwZ088DeQJRE9wznglTsQo0VijOaJaxJzMXDoPfT89XmKS5ZxeFscCZdxZB6XO+ICbOLCH1wYBP+K7/fsEaBzP//jC0dL3/QSE01cuKGXikZMcRNcvCFunMrIxCENl7rhdkzKE/T2rDquRYeohrNEl1ujwxdGh4g2KJbo1ubSJs5sHaaphrO0bmWt/NWEjbJhqpctchN10fLCVLfRcXnN2jg2IF3CJXHitp13NRcHVQEmxGlaAUwMYKo7Ss9PHw==",BinaryEncoding.Base64),Compression.Deflate))),
    chtype = Table.TransformColumnTypes(Source,{{"Date", type date}}),
    group = Table.Group(chtype, {"Project"}, {{"Start Date", each List.Min([Date]), type date},{"End Date", each List.Max([Date]), type date}})
in
    group

 

 

 

View solution in original post

5 REPLIES 5
ziying35
Impactful Individual
Impactful Individual

@bucket 

Power Query:

 

 

// output
let
    Source = Table.FromRecords(Json.Document(Binary.Decompress(Binary.FromText("rZRLa4QwFIX/imQdMInPuKstQ7sQhnZZuwhOoHZCLD6gQ5n/3khfsTHaCe5iCHyec+65j+9g3zYvvOpB9n3yrgEERS141zeSg0wOQkBwz7tmaCv1DQom6uoIvYK1fS3V4xvWj/dp6QelTxBB6u5Wve5ARkgEwZ088DeQJRE9wznglTsQo0VijOaJaxJzMXDoPfT89XmKS5ZxeFscCZdxZB6XO+ICbOLCH1wYBP+K7/fsEaBzP//jC0dL3/QSE01cuKGXikZMcRNcvCFunMrIxCENl7rhdkzKE/T2rDquRYeohrNEl1ujwxdGh4g2KJbo1ubSJs5sHaaphrO0bmWt/NWEjbJhqpctchN10fLCVLfRcXnN2jg2IF3CJXHitp13NRcHVQEmxGlaAUwMYKo7Ss9PHw==",BinaryEncoding.Base64),Compression.Deflate))),
    chtype = Table.TransformColumnTypes(Source,{{"Date", type date}}),
    group = Table.Group(chtype, {"Project"}, {{"Start Date", each List.Min([Date]), type date},{"End Date", each List.Max([Date]), type date}})
in
    group

 

 

 

Thank you!  

Oh yeah, Power Query, I always forget to check which forum things are in!



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

@bucket  - This should be something like:

Table = 
  SUMMARIZE('Table',[Project],"Start Date",MIN('Table'[Date]),"End Date",MAX('Table'[Date]))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

I think the tutorial you've been looking at will leave you more confused.

 

In Power Query, select the 'Group By' from the ribbon.

Click Advanced.

Put Project in the groupby field.

Use 2 aggregations, both on the Date column : one will be 'startDate' for column name, Operation : Min

one will be 'endDate' for column name, Operation : Max

 

 

good luck.

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

August Carousel

Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors