Sep 16
Earlier I wrote about <a href="https://www.dynamicpeople.nl/en/news/creative-solution-for-customers-needs/" aria-label="How to make a Gantt chart with DAX in Power BI.“>How to make a Gantt chart with DAX in Power BI.I promised a part 2, and here it is! Read all about how we created a custom Gantt chart using the default Power BI Matrix visual and Dax.
First, let’s take a look at our (simplified) data model to understand what we are working with.

The activity table contains all information about the activities and their start and end dates. There is also a parent column to group the activities into a hierarchy. For all the associated milestones, a separate table is included that show each milestone date on a separate row, with its current status and a key to the activity it belongs to. We added a calculated column to the Activity table that calculated the upcoming due date and called it “Next Assessment Due Date”.
The date table “Calendar” does not have a relationship with any of the other tables, because we do not want this table to influence the filter context of the other table(s). These dates are used in the matrix to:
Now let’s get started with the matrix visual.
The visual results in an error now, because there is no relationship between the Calendar and Activity table. The DAX measure will create that relationship and resolve the error.

First, the part of the measure that checked if the activity is (or was) active in the selected period is defined and tested:
The result in the matrix shows 1’s for active and blanks for inactive activities. The results are checked by looking at the start and end dates in the activity details table below.

Then, the logic for the milestones was defined. The final chart should visually show the statuses of the milestones with icons, so I pre-coded them:
– IsActive = 1
– NextAssessmentDate = 2
– DueDatePending = 3
– DueDateCompleted = 4
– DueDateCancelled = 5
This results in the following DAX code, where the first measure is transformed in a variable and for all other numeric numbers a new variable is added. The numbers that are returned will reflect the status of the activity or the status of the milestone as written out above.
Is active or has milestone in selected period =
Drag the new measure into the value field of the matrix visual and check the results. The matrix is now showing our numeric code.

Now conditionally format the numbers to mimic bars over time and visualize the milestones with icons. Use the Background, Font and Icons options to visually inform the report user what the status is of each milestone for any of the activities.

Do you have specific wishes for you Gantt Chart, that Power BI or the custom visuals from the Appsource, do not seem to meet? Let us know, we would love to think along.