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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
maibacherstr
Helper III
Helper III

DAX HEROES NEEDED: Re-writing VBA into a Measure (MS Project: Task.PathDrivingPredecessor)

Hello Power BI Community,

 

There is a potent but little-known feature in MS Project known as Task.PathDrivingPredecessor, which according to MSFT documentation "gets a value that indicates whether the task is a predecessor that drives the selected task, when the Driving Predecessors item is selected in the Task Path drop-down list. Read-only Boolean."

 

Based on initial research, this feature has not been made available to Power BI, but would be a giant win for the community for anyone interested to take notice of this analytical gem.

 

However, the VBA is not simple. The below code (which is copied from the documentation linked above) returns true/false for task predecessors when a given task is selected. If written as a measure, the measure will dynamically change conditional formats as you click through rows of the project schedule once connected to and added into Power BI.

 

This might need the heroes' attention. Go ahead, be a hero! Thank you in advance.

 

 

Option Explicit

Sub TestTaskPath()
Dim t As Task
Dim chkTsk As Task
Dim selectedTaskId As Integer

For Each t In ActiveProject.Tasks
selectedTaskId = t.ID
Application.SelectRow Row:=selectedTaskId, RowRelative:=False

If Not (ActiveSelection.Tasks Is Nothing) Then
Debug.Print

With ActiveSelection.Tasks(1)
Debug.Print "Selected task ID " & .UniqueID & ", name: " & .Name
End With

For Each chkTsk In ActiveProject.Tasks
If Not (chkTsk.ID = selectedTaskId) Then
If chkTsk.PathPredecessor Then
Debug.Print vbTab & chkTsk.Name & ": PathPredecessor"
End If
If chkTsk.PathDrivingPredecessor Then
Debug.Print vbTab & chkTsk.Name & ": PathDrivingPredecessor"
End If
If chkTsk.PathSuccessor Then
Debug.Print vbTab & chkTsk.Name & ": PathSuccessor"
End If
If chkTsk.PathDrivenSuccessor Then
Debug.Print vbTab & chkTsk.Name & ": PathDrivenSuccessor"
End If
End If
Next chkTsk
End If
Next t
End Sub

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @maibacherstr 

 

You can refer to the following link, hope it can help you.

How to use VBA to create DAX measures automatically - YouTube

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

maibacherstr
Helper III
Helper III

I found the following blog to contain a lot of promising code and instruction, but still believe this topic calls for practically expert-level skills.

 

TaskPathDrivingPredecessorFilter – TomsBlog (boyleprojectconsulting.com)

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.