March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
For example, I have 3 tasks that all have an immediate preceding relationship,task2 start as task1 finished,
1 <- 2 <- 3
task1 has a scheduled start time of 1 and a scheduled completion time of 1, 2 has a scheduled start time of 1 and a scheduled completion time of 2, and so on.
Now the problem is, if due to 1, task 2 is not started, so the completion time is also delayed, in this case, the assessment criteria is only task 1 is not completed, the delay is 1 day, task 2, 3 is normal, the assessment is "actual completion time" - "planned completion time ", so the last column should be 1, are delayed by one day, but task 2, 3 is due to task 1 delay caused by, so to remove the 2 tasks of the delay to 0,how can i do this using Dax?
TaskID | PlanedStart | PlanFinish | ActualStart | ActualFinish | Predecessor | DeLay | ActualDelay |
1 | 1 | 1 | 1 | 2 | 1 | 1 | |
2 | 2 | 2 | 3 | 3 | 1 | 1 | 0 |
3 | 3 | 3 | 4 | 4 | 2 | 1 | 0 |
To achieve this in DAX, you can create a calculated column for ActualDelay. Here's how you can do it:
First, you need to determine if the task's actual start time is delayed due to its predecessor. If the task's actual start time is greater than its planned start time and the predecessor's actual finish time is greater than the predecessor's planned finish time, then the task is delayed due to its predecessor.
Now, for the ActualDelay calculation:
If a task is delayed due to its predecessor, set ActualDelay to 0. Otherwise, calculate the delay as the difference between the actual finish time and the planned finish time.
Here's the DAX formula for the ActualDelay column:
ActualDelay =
VAR CurrentTaskID = Tasks[TaskID]
VAR PredecessorID = Tasks[Predecessor]
VAR PredecessorActualFinish = LOOKUPVALUE(Tasks[ActualFinish], Tasks[TaskID], PredecessorID)
VAR PredecessorPlanFinish = LOOKUPVALUE(Tasks[PlanFinish], Tasks[TaskID], PredecessorID)
RETURN
IF(
AND(
Tasks[ActualStart] > Tasks[PlanedStart],
PredecessorActualFinish > PredecessorPlanFinish
),
0,
Tasks[ActualFinish] - Tasks[PlanFinish]
)
In this formula, we're using the LOOKUPVALUE function to get the actual and planned finish times of the predecessor task. We then determine if the current task is delayed due to its predecessor. If it is, we set ActualDelay to 0. Otherwise, we calculate the delay as the difference between the actual and planned finish times.
I hope this helps! Let me know if you have any questions or need further clarification.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
22 | |
19 | |
16 | |
9 | |
5 |
User | Count |
---|---|
37 | |
29 | |
16 | |
14 | |
12 |