Forum Discussion

seaborne's avatar
seaborne
Helper I
6 years ago
Solved

Calculated critical path table using two columns with MAX(Finish) of a third date column

Hello all,

In scheduling terms, I am trying to build a calculated Critical Path table. I want to return the last Project to finish per Building based on the MAX finish date of the activities within each project. 

 

BuildingProjectActivityFinishDate
AReplace RoofDemo old1/1/2020
AReplace Roofreplace wood1/2/2020
AReplace Roofcoat1/3/2020
AReplace Roofinspect roof1/4/2020
APaint WallsScrape1/15/2020
APaint WallsSand1/16/2020
APaint WallsPrimer1/17/2020
APaint WallsPaint1/18/2020
APaint WallsInspect walls1/19/2020
BAdd WifiPurchase equipment1/10/2020
BAdd WifiRun cable1/11/2020
BAdd Wifiinstall repeaters1/12/2020
BReplace CarpetDemo old1/7/2020
BReplace Carpetreplace padding1/8/2020
BReplace Carpetreplace carpet1/9/2020
BReplace Carpetinspect carpet1/10/2020

 

Should result in a table like the following...

 

BuildingProjectFinish
APaint Walls1/19/2020
BAdd Wifi1/12/2020

 

If I could also return the activity name of the last activity, bonus points!

 

Thanks in advance. My first post to this forum. I have found the posts here extremely helpful and the responders to be patient and polite.

 

 

 

7 Replies

  • Hi,

    This M code works

    let
        Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Building", type text}, {"Project", type text}, {"Activity", type text}, {"FinishDate", type datetime}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Building"}, {{"Last Date", each List.Max([FinishDate]), type datetime}}),
        Joined = Table.Join(Source, "Building", #"Grouped Rows", "Building"),
        #"Added Custom" = Table.AddColumn(Joined, "Custom", each [FinishDate]=[Last Date]),
        #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] = true)),
        #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"FinishDate", "Custom"}),
        #"Changed Type1" = Table.TransformColumnTypes(#"Removed Columns",{{"Last Date", type date}})
    in
        #"Changed Type1"

    Hope this helps.

    • seaborne's avatar
      seaborne
      Helper I

      Thank you! That was fast. I'm off to apply logic to procuction tables which have many more columns. I will reply back and mark as Solution if this does it.

  • Update... client just asked for the last 2 Projects to finish per Building. For reference, there are hundreds of Projects per Building in their schedule. This is Critical Path and Next Critical Path in scheduling terms.

      • seaborne's avatar
        seaborne
        Helper I

        Downloaded the pbix file. Thank you again. Off to play with it... this is different approach using RANK.