Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register 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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |