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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
psabbag
Frequent Visitor

Number of days between milestone dates in same column which relate to another column

I have a data set where I have a customer name and 3 rows of that customer's milstone dates of 3 key points. I am trying to calculate the number of business days between milestone A & B and between B & C. Sample data below where column D would show the calculated number of business days.

 

CUSTOMERTASKDATEDAYS BETWEEN MILESTONES
ACMESTART11/1/2020 
ACMEDATA COLLECTION11/20/202019
ACMECOMPLETE12/5/202015
ABC WIDGETSSTART10/15/2020 
ABC WIDGETSDATA COLLECTION10/25/202010
ABC WIDGETSCOMPLETE1/2/202169
WORLDWIDESTART12/25/2020 
WORLDWIDEDATA COLLECTION1/30/202136
WORLDWIDECOMPLETE2/6/20217
XYZ PLUMBINGSTART12/1/2020 
XYZ PLUMBINGDATA COLLECTION1/3/202133
XYZ PLUMBINGCOMPLETE2/20/202148
4 REPLIES 4
Anonymous
Not applicable

@psabbag 

 

I understand you don't need a measure but a calculated column. Here it is:

 

[Days Between Milestones] = // calculated column
var CurrentCust = T[Customer] // T is your table
var CurrentTask = T[Task]
var Result =
    SWITCH( CurrentTask,
    
        "data collection",
            var DataCollectionTaskDate = T[Date]
            var StartTaskDate =
                MAXX(
                    FILTER(
                        T,
                        T[Customer] = CurrentCust
                        &&
                        T[Task] = "start"
                    ),
                    // The filter guarantees
                    // there'll be only one date.
                    T[Date]
                )
            return
                DataCollectionTaskDate - StartTaskDate,
                
        "complete",
            var CompleteTaskDate = T[Date]
            var DataCollectionTaskDate =
                // The filter guarantees
                // there'll be only one date.
                MAXX(
                    FILTER(
                        T,
                        T[Customer] = CurrentCust
                        &&
                        T[Task] = "data collection"
                    ),
                    T[Date]
                )
            return
                CompleteTaskDate - DataCollectionTaskDate,
        
        
        "start", BLANK()
    )
return
    Result

 

 

thanks for this - I am getting an erro message regarding minimum of 2 arguments

Anonymous
Not applicable


@psabbag wrote:

thanks for this - I am getting an erro message regarding minimum of 2 arguments


Try once again the measure above.

Jihwan_Kim
Super User
Super User

Hi, @psabbag 

Please try the below-calculated measure.

 

Days Between Milestones =
VAR currentdate =
MAX ( 'Table'[DATE] )
VAR result =
CALCULATE (
MAX ( 'Table'[DATE] ),
FILTER ( ALL ( 'Table' ), 'Table'[DATE] < currentdate ),
VALUES ( 'Table'[CUSTOMER] )
)
RETURN
DATEDIFF ( result, SELECTEDVALUE ( 'Table'[DATE] ), DAY )

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster.

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.