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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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.


Go to My LinkedIn Page


Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors