How to create a Gantt chart in Power BI: step by step
This tutorial shows how to create a Gantt chart in Power BI to visualize tasks, start and end dates, duration and percentage complete — useful for project management and planning. I will explain why a Gantt helps understand dependencies and progress and how to build the visual with simple data and DAX measures.
Prerequisites
- Power BI Desktop installed
- A table with columns: Task, StartDate, EndDate, PercentComplete
- Basic knowledge of Power Query and DAX
Step 1: Prepare the data (Power Query)
Import your table into Power BI Desktop (Excel, CSV or another source). Verify that StartDate and EndDate are in date format. If necessary, use Power Query to convert texts to dates and remove empty rows.
// Exemplo em M no editor do Power Query para garantir tipos
let
Fonte = Excel.Workbook(File.Contents("C:\projeto\tasks.xlsx"), null, true),
Tabela = Fonte{[Name="Tasks"]}[Data],
Tipo = Table.TransformColumnTypes(Tabela,{{"Task", type text}, {"StartDate", type date}, {"EndDate", type date}, {"PercentComplete", type number}})
in
Tipo
Step 2: Create helper columns (Duration and Order)
On the Modeling tab create a calculated column for duration in days and another to sort tasks (optional). Duration is required to represent the width of the bars in the Gantt.
// Coluna Duracao (dias)
Duracao = DATEDIFF('Tasks'[StartDate], 'Tasks'[EndDate], DAY)
// Coluna Ordem (exemplo por StartDate para ordenar o eixo)
OrdemTarefa = RANKX(ALL('Tasks'), 'Tasks'[StartDate], , ASC, DENSE)
Step 3: Build the horizontal axis (continuous dates)
A Gantt needs a continuous date axis. If you don’t have a date table, create a simple one using DAX. This table helps align bars correctly on the time axis.
// Tabela Calendario básica
Calendario =
ADDCOLUMNS(
CALENDAR(MIN('Tasks'[StartDate]), MAX('Tasks'[EndDate])),
"Ano", YEAR([Date]),
"Mes", MONTH([Date])
)
Step 4: Create measures to start the Gantt
Create measures that calculate the start position and the duration in numeric form for use in the visual (some custom visuals or the stacked bar technique).
// Início em número de dias desde a data mínima (para gráfico empilhado)
DataMin = MIN('Calendario'[Date])
StartOffset =
DATEDIFF(MIN('Calendario'[Date]), MIN('Tasks'[StartDate]), DAY)
// Alternativa: medida por task usando SELECTEDVALUE
StartOffsetTask =
VAR d0 = CALCULATE(MIN('Tasks'[StartDate]), ALLSELECTED())
RETURN DATEDIFF(MIN('Calendario'[Date]), d0, DAY)
Step 5: Create the Gantt visual with a stacked bar chart (technique without custom visual)
If you don’t want to install a custom visual, use a stacked bar chart with two series: an invisible series for the offset (start) and another for the duration. Configure the y axis with Task sorted by the Order column.
- Insert a Stacked Bar chart.
- On the 'Axis' put Task (use Sort by column OrdemTarefa).
- In 'Legend' leave blank; in 'Values' add: StartOffset as the first series and Duracao as the second series.
- Formatting: set the first series color to transparent (or 0% opacity). The second series represents the Gantt bar.
- Enable data labels to show PercentComplete or create an additional visual marker.
Step 6: Show PercentComplete inside the Gantt
You can represent progress with a second bar segment inside the duration (internal stacking) or with labels. Create measures for DuracaoCompleta and DuracaoConcluida and use them as stacked series.
// DuracaoConcluida em dias
DuracaoConcluida = SUMX('Tasks', 'Tasks'[Duracao] * 'Tasks'[PercentComplete] / 100)
// DuracaoRestante
DuracaoRestante = SUM('Tasks'[Duracao]) - [DuracaoConcluida]
Then, on the stacked chart put: Offset (invisible), DuracaoConcluida (distinct color) and DuracaoRestante (base color). This way you see a bar with the completed portion.
Verify the result
Confirm that the bars start on the correct dates by comparing StartDate with the start point on the axis. Check that the sum of DuracaoConcluida and DuracaoRestante equals Duracao for each task. Common errors: dates with time components (convert to date), negative durations (EndDate before StartDate) or unsorted fields (use OrdemTarefa).
Conclusion
You now have a functional Gantt in Power BI without the need for custom visuals, with Start, End, duration and progress visualized. Next steps: try a Gantt visual from AppSource for advanced features (dependencies, milestones) or create custom tooltips with more detail. Tip: always validate dates and use a Calendario table to avoid misalignments — which task would you like to schedule first?