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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

Summaries table with Earliest date / Latest date with condition

Dear Community 

I have the following issue

There are multiple projects (more than 200) . Each projects has multible discipline and each discipline has diffrent tasks in original data set. Please see sample data below. I would like to summarise data into a table and then a gant chart:  Project name, Discipline name, start date, finish date . So table should use the earliset start date as summary start date and the latest finish date as summary finish date what the earliest date and the latest date is per disicpline 

I am new in DAX and  tried to use this formulat but seems doesn't work:

 

eStartDate =
    CALCULATE (
        MIN ( 'Table1'[Start] ),
        FILTER (
            'Table1',
            [Start] <= EARLIER ( 'Table1'[Name] )
                               && 'Table1'[Name] = EARLIER ( 'Table1'[FY] )
           
        )
    )
RETURN
    IF (
        [Start] <> BLANK ()
            && [Finish] <> BLANK ()
           )

EFinishDate =
    CALCULATE (
        MAX ( 'Table1'[Finish] ),
        FILTER (
            'Table1',
            [Finish] >= EARLIER ( 'Table1'[Finish] )
                && 'Table1'[Name]= EARLIER ( 'Table1'[FY] )
        )
    )
RETURN
    IF (
        [Start] <> BLANK ()
            && [Finish] <> BLANK (),
           )

 

here is original data:

Project NameNameDisciplineStartFinishFY
Ramp A     
Grand RoadRamp A - Physical work StartRamp A 13-Nov-24  
Grand RoadRamp A - Physical work CompletionRamp A  7-Dec-252026
Grand RoadRamp A - Defect CompletionRamp A  10-Feb-26 
Grand RoadRamp A -Operational ReadynessRamp A  15-Apr-26 
Access B     
Grand RoadAccess B - Physical work StartAccess B7-Mar-23  
Grand RoadAccess B - Physical work CompletionAccess B7-Mar-2328-Aug-252026
Grand RoadAccess B- Defect CompletionAccess B 16-Nov-25 
Control Unit     
Grand RoadControl Unit - Physical work StartControl Unit22-Aug-24  
Grand RoadControl Unit - Physical work CompletionControl Unit22-Aug-2431-Mar-252025
Grand RoadControl Unit - Defect CompletionControl Unit1-Nov-2428-Apr-252026
Grand RoadControl Unit -Operational ReadynessControl Unit 15-Sep-25 
      
Road Landscape     
Holt AveRoad Landscape - Physical work StartRoad Landscape16-Jan-23  
Holt AveRoad Landscape- Physical work CompletionRoad Landscape16-Jan-2311-Aug-232024
Holt AveRoad Landscape - Defect CompletionRoad Landscape 14-Feb-24 
Holt AveRoad Landscape -Operational ReadynessRoad Landscape14-Feb-2414-Feb-24 
StormWater Tank      
Holt AveStormWater Tank  - Physical work StartStormWater Tank 1-Mar-22  
Holt AveStormWater Tank - Physical work CompletionStormWater Tank 31-Mar-23 2023
Holt AveStormWater Tank  Defect CompletionStormWater Tank  31-Dec-24 
Holt AveStormWater Tank  -Operational ReadynessStormWater Tank  1-Mar-25 

 

Summarised table should be like this

Project NameNameStartFinishFY
Grand RoadRamp A13-Nov-2415-Apr-262027
Grand RoadAccess B7-Mar-2316-Nov-252026
Grand RoadControl Unit22-Aug-2415-Sep-252026
Holt AveRoad Landscape16-Jan-2314-Feb-242024
Holt AveStormWater Tank 1-Mar-221-Mar-252025

 

And summarise gant visual like this:

Narsis_0-1715553879950.png

Can anyone help me with this?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

Thanks for your reply. If you can't create a new calculation table. You can create a measure as follows:

start date = 
VAR _table = CALCULATETABLE (
    SUMMARIZE (
        FILTER ( 'Table', 'Table'[Name] <> BLANK () ),
        'Table'[Project Name],
        'Table'[Discipline],
        "start", CALCULATE ( MIN ( 'Table'[Start] ) ),
        "Finish", CALCULATE ( MAX ( 'Table'[Finish] ) ),
        "FY", VAR _maxday = MAX ( 'Table'[Finish] ) RETURN YEAR ( _maxday )
    )
)
VAR _project_name = SELECTEDVALUE('Table'[Project Name])
VAR _discipline = SELECTEDVALUE('Table'[Discipline])
RETURN CALCULATE(
    MAX([Start]),
    FILTER(_table,
        'Table'[Discipline]=_discipline&&'Table'[Project Name]=_project_name
    )
)
End date = 
VAR _table = CALCULATETABLE (
    SUMMARIZE (
        FILTER ( 'Table', 'Table'[Name] <> BLANK () ),
        'Table'[Project Name],
        'Table'[Discipline],
        "start", CALCULATE ( MIN ( 'Table'[Start] ) ),
        "Finish", CALCULATE ( MAX ( 'Table'[Finish] ) ),
        "FY", VAR _maxday = MAX ( 'Table'[Finish] ) RETURN YEAR ( _maxday )
    )
)
VAR _project_name = SELECTEDVALUE('Table'[Project Name])
VAR _discipline = SELECTEDVALUE('Table'[Discipline])
RETURN CALCULATE(
    MAX([Finish]),
    FILTER(_table,
        'Table'[Discipline]=_discipline&&'Table'[Project Name]=_project_name
    )
)

Use these two measures in your Gantt chart:

vjianpengmsft_0-1715586488673.png

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project Name", type text}, {"Name", type text}, {"Discipline", type text}, {"Start", type date}, {"Finish", type date}, {"FY", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Project Name] <> null and [Project Name] <> ""),
    #"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each [Name] <> null and [Name] <> ""),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows1",{"Name"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"Project Name", "Discipline"}, {{"Start", each List.Min([Start]), type nullable datetime}, {"End", each List.Max([Finish]), type nullable datetime}})
in
    #"Grouped Rows"

I do not know how to get the FY.


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

Thanks I will make a try. 

for now I created two columns summary start date and summary finish date with project and discipline filter: 

 

SummaryFinishDate =
VAR ProjectName = 'Table1'[Project Name ]
VAR DisciplineName = 'Table1'[Discipline]

 

RETURN
    CALCULATE(
        MAX('Table1'[Finish].[Date]),
        FILTER(
            'Table1',
            'Table1'[Project Name ] = ProjectName &&
            'Table1'[Discipline] = Disciplinename
        )
    )
 
And it works for Table and linked Gantt.
Anonymous
Not applicable

Hi  v-jianpeng-msft

Thanks for your Response. I can't create a new Table as I have to add more columns/value from current data set to my visual once early start and late finish summary sortted. And also there is not a unique ID/cpde to make a relationship between data sets or Tables. May have to create  multiple columns in my current data set. Any Idea?

I am trying with this DAX :

SummaryFinishDate =
VAR ProjectName = 'Table1'[Project Name ]
VAR DisciplineName = 'Table1'[Discipline]

RETURN
    CALCULATE(
        MAX('Table1'[Finish].[Date]),
        FILTER(
            'Table1',
            'Table1'[Project Name ] = ProjectName &&
            'Table1'[Discipline] = Disciplinename
        )
    )

 

Anonymous
Not applicable

Hi @Anonymous 

Thanks for your reply. If you can't create a new calculation table. You can create a measure as follows:

start date = 
VAR _table = CALCULATETABLE (
    SUMMARIZE (
        FILTER ( 'Table', 'Table'[Name] <> BLANK () ),
        'Table'[Project Name],
        'Table'[Discipline],
        "start", CALCULATE ( MIN ( 'Table'[Start] ) ),
        "Finish", CALCULATE ( MAX ( 'Table'[Finish] ) ),
        "FY", VAR _maxday = MAX ( 'Table'[Finish] ) RETURN YEAR ( _maxday )
    )
)
VAR _project_name = SELECTEDVALUE('Table'[Project Name])
VAR _discipline = SELECTEDVALUE('Table'[Discipline])
RETURN CALCULATE(
    MAX([Start]),
    FILTER(_table,
        'Table'[Discipline]=_discipline&&'Table'[Project Name]=_project_name
    )
)
End date = 
VAR _table = CALCULATETABLE (
    SUMMARIZE (
        FILTER ( 'Table', 'Table'[Name] <> BLANK () ),
        'Table'[Project Name],
        'Table'[Discipline],
        "start", CALCULATE ( MIN ( 'Table'[Start] ) ),
        "Finish", CALCULATE ( MAX ( 'Table'[Finish] ) ),
        "FY", VAR _maxday = MAX ( 'Table'[Finish] ) RETURN YEAR ( _maxday )
    )
)
VAR _project_name = SELECTEDVALUE('Table'[Project Name])
VAR _discipline = SELECTEDVALUE('Table'[Discipline])
RETURN CALCULATE(
    MAX([Finish]),
    FILTER(_table,
        'Table'[Discipline]=_discipline&&'Table'[Project Name]=_project_name
    )
)

Use these two measures in your Gantt chart:

vjianpengmsft_0-1715586488673.png

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi, @Anonymous 

Depending on your description, you can try the following DAX expressions:

Table 2 = 
CALCULATETABLE (
    SUMMARIZE (
        FILTER ( 'Table', 'Table'[Name] <> BLANK () ),
        'Table'[Project Name],
        'Table'[Discipline],
        "start", CALCULATE ( MIN ( 'Table'[Start] ) ),
        "Finish", CALCULATE ( MAX ( 'Table'[Finish] ) ),
        "FY", VAR _maxday = MAX ( 'Table'[Finish] ) RETURN YEAR ( _maxday )
    )
)

 The summary table is as follows:

vjianpengmsft_0-1715566005132.png

You can then use these fields in your gant plot as follows:

vjianpengmsft_1-1715566087236.png

You can look for the Gantt chart you want from the visual marketplace:

vjianpengmsft_2-1715566166338.png

vjianpengmsft_3-1715566192234.png

I've provided the PBIX file used this time below.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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