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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
nmeliasp
Regular Visitor

datediff calculating milestone completion cycle time

Hello i have the following data and trying to calculate date difference in days between 2 different milestone completions

 

IdentiferMilestone CompletionCompletion date
AX1/1/2018
AY1/23/2018
BX1/8/2018
BY1/15/2018
CX1/10/2019
CY1/20/2019

 

My desired output is below

IdentiferDate Diff in Days
A22
B7
C10

 

I need to figure out how to write a DAX expression to give me my desired output table. Do i need to calculate a new table. I am thinking of needing to use DATEDIFF and GROUPBY but not sure if that is the right approach and looking for suggestions

1 ACCEPTED SOLUTION

Hi @nmeliasp

 

You may use ALLEXCEPT Function as below:

Measure = 
VAR MAX_Date =
    CALCULATE (
        MAX ( Table1[Completion date] ),
        ALLEXCEPT(Table1,Table1[Identifer])
    )
VAR MIN_Date =
    CALCULATE (
        MIN( Table1[Completion date] ),
        ALLEXCEPT(Table1,Table1[Identifer])
    )
RETURN
    DATEDIFF ( MIN_Date,MAX_Date, DAY )

1.png

 Regards,

Cherie

Community Support Team _ Cherie Chen
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,

 

Drag Identifier to the row labels and use this measure

 

Date Diff in Days = MAX(Data[Completion_Date])-MIN(Data[Completion_Date])


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

@nmeliasp

 

Try this MEASURE..Drag Identifier and this MEASURE in a Table Visual

 

Measure =
VAR MilestoneY =
    CALCULATE (
        MAX ( Table1[Completion date] ),
        Table1[Milestone Completion] = "Y"
    )
VAR MilestoneX =
    CALCULATE (
        MAX ( Table1[Completion date] ),
        Table1[Milestone Completion] = "X"
    )
RETURN
    DATEDIFF ( MilestoneX, MilestoneY, DAY )

 

 

This doesnt seem to have worked. I dont see anything for this measure. 

Hi @nmeliasp

 

You may use ALLEXCEPT Function as below:

Measure = 
VAR MAX_Date =
    CALCULATE (
        MAX ( Table1[Completion date] ),
        ALLEXCEPT(Table1,Table1[Identifer])
    )
VAR MIN_Date =
    CALCULATE (
        MIN( Table1[Completion date] ),
        ALLEXCEPT(Table1,Table1[Identifer])
    )
RETURN
    DATEDIFF ( MIN_Date,MAX_Date, DAY )

1.png

 Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Awesome that worked!!!

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.