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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
emilyh1
Frequent Visitor

Specific Filtering in a Gannt Chart Based Off Parent Level

I am wanting to be able to filter differently for each different Project, at the parent level. 

 

If I select Project1 in a slicer, I only want certain Task items to appear at the task level for that project in the Gantt Chart. I do not need all tasks to show up on the chart. For example, in Project1, there are Tasks 1-9. I only want Tasks 2,4,6 to show up on the chart.

 

Now, if I would switch to Project2, I want the related task items to show up in the Gantt Chart based off the filter specific to Project2. For example, Project2 has Tasks 1-15. I want Tasks 1,3,6,7,8 to show up on the Gantt. 

 

The task level items for Project1 and Project2 are not the same and cannot have the same filters applied to them. I do not want the same task numbers to show up on the Gantt chart each time I switch to a different project. 

 

Is there a DAX code that will filter tasks based off the Project that has been selected? 

     I was wondering if an IF statement or a SWITCH statement and paired with a FILTER statement, if any of those would work? 

1 REPLY 1
Anonymous
Not applicable

Hi @emilyh1 ,
Based on your description, you can indeed use a switch statement to accomplish your goal, as you can see in this dax example:

DynamicFilteredTasks = CALCULATE(
    COUNTROWS(Tasks),
    FILTER(
        Tasks,
        SWITCH(
            SELECTEDVALUE(Projects[ProjectName]),
            "Project1", Tasks[TaskID] IN {2, 4, 6},
            "Project2", Tasks[TaskID] IN {1, 3, 6, 7, 8},
            FALSE()
        )
    )
)

You can follow the above dax logic to create the dax you need, if you still can't solve the problem, please provide the pbix file, so that we can help you faster, please hide the privacy information in advance.

Best regards,

Albert He

 

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.