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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
x-File
Helper I
Helper I

One max end date per project even if there are multiple rows with the same max end date

Hi all,

 

Suppose I have a table like the following, with multiple sub projects (all with a unique title): 

 

Sub ProjectPhaseStart DateEnd DateMax End Date
Project XGroup 101/08/202301/11/202301/11/2023
Project XGroup 201/08/202301/11/202301/11/2023
Project XGroup 301/06/202301/10/202301/11/2023
Project XGroup 401/07/202301/09/202301/11/2023


When doing some formula in Power Query, I can get the Min and Max Date preatty easily per project, but it will then apply that to all rows - which is not what I want, I want it to apply to just one row per sub project, which I can do as well, but it goes wrong when I have two groups from the same project that have exaclty identical Sub Project en Start or End dates. In this case, Group 2 and 3 from Projext X are exactly identical in their timelines.

What I want is this:

Sub ProjectPhaseStart DateEnd DateMax End Date
Project XGroup 101/08/202301/11/202301/11/2023
Project XGroup 201/08/202301/11/2023blank
Project XGroup 301/06/202301/10/2023blank
Project XGroup 401/07/202301/09/2023blank


I already grouped my table by sub project, and that worked fine so every sub project had just one row with start en end dates, however when I merged it back with the original table, it apllied to two rows.

 

If you people could help me, I'd be very very very happy!

 

best,

 

Felix

1 REPLY 1
Vijay_A_Verma
Super User
Super User

Whatever I could understand, check the below sample code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKz0pNLlGIUNJRci/KLy1QMASyDPUt9I0MjIzBTENDCDtWB5tyI9KUQ9SYISk3wKfcBKzGHKHcElN1JG6nGxnhU06U0yNxO93IFKo8FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Sub Project" = _t, Phase = _t, #"Start Date" = _t, #"End Date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Sub Project", type text}, {"Phase", type text}, {"Start Date", type date}, {"End Date", type date}}),
    #"Grouped Rows" = Table.Combine(Table.Group(#"Changed Type", {"Sub Project"}, {{"All", each Table.FromColumns(Table.ToColumns(_) & {{List.Max(_[End Date])} & List.Repeat({null}, Table.RowCount(_)-1)}, Table.ColumnNames(_) & {"Max End Date"})}})[All])
in
    #"Grouped Rows"

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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