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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
seaborne
Helper I
Helper I

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.

 

 

 

1 ACCEPTED SOLUTION

Hi,

You may download my PBI file from here.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
seaborne
Helper I
Helper I

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.

Hi,

You may download my solution PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Apologies. The desired result is to show the last "N" projects to complete per building, with the last activity for each project (display this optionally - not a current requirement). The rankx solution with a filter applied for "N" is a good solution. But the attached pbix file appears to rank the last two activities within each Project. It shows two activities for the same Project per building. I only want to show the last activity per Project. The ranking should be at the Project level.

 

BuildingProjectActivityFinish
APaint WallsInspect walls1/19/2020
BAdd Wifiinstall repeaters1/12/2020

Hi,

You may download my PBI file from here.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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

Ashish_Mathur
Super User
Super User

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.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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