Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
when users select a date range using the slicer, the Gantt chart will dynamically adjust to display only the project activities that fall within the selected date range while still showing all projects. Projects that don't have any activities within the selected date range will appear as empty bars on the Gantt chart.
Hi @yuvi12 ,
Try this steps
Insert a Gantt chart visual into your Power BI report.
Drag and drop the project name or ID into the "Values" field well of the Gantt chart visual.
Drag the activity start date and activity end date into the "StartDate" and "EndDate" field wells of the Gantt chart visual.
Click on the Gantt chart visual to select it.
Go to the "Format" pane.
Under the "Filters" section, select the "Filters on this visual" option.
Click on the date column you added to the slicer to create a filter.
Choose the "Between" filter type.
This will filter the Gantt chart based on the selected date range.
To display projects that don't have any activities within the selected date range as empty bars, you'll need to create a measure to calculate the status of each project within the date range.
Go to the "Modeling" tab in Power BI.
Click on "New Measure" and create a DAX measure that checks if any activities for a project fall within the selected date range.
For example:
ProjectStatus =
IF (
MIN(YourActivityTable[StartDate]) >= MIN(DateSlicer[Date]) &&
MAX(YourActivityTable[EndDate]) <= MAX(DateSlicer[Date]),
"In Range",
"Out of Range"
)
Drag and drop the "ProjectStatus" measure you created into the "Values" field well of the Gantt chart visual.
Set the aggregation for this measure to "Don't Summarize."
Let me know id this work, and if not please share a screenshort with the problem.
Thanks
Babatunde Dallas
Hello @yuvi12,
Here is a basic guide that might assist:
1. Ensure your data has columns for ProjectName, ActivityStartDate, and ActivityEndDate. Create a a slicer visual onto your canvas and use the ActivityStartDate as the field.
2. Use a Gantt chart custom visual from the Power BI marketplace if you haven't already done so
3. This is the trickier part. You want the Gantt chart to show all projects but only highlight the activities within the selected date range:
Filtered Start Date =
IF(
MIN('Table'[ActivityStartDate]) >= MIN(SlicerTable[ActivityStartDate]) &&
MAX('Table'[ActivityEndDate]) <= MAX(SlicerTable[ActivityEndDate]),
MIN('Table'[ActivityStartDate]),
BLANK()
)
Filtered End Date =
IF(
MIN('Table'[ActivityStartDate]) >= MIN(SlicerTable[ActivityStartDate]) &&
MAX('Table'[ActivityEndDate]) <= MAX(SlicerTable[ActivityEndDate]),
MAX('Table'[ActivityEndDate]),
BLANK()
)
Should you require any further assistance, please do not hesitate to reach out to me.
This approach didn't work for me because I only have one date dimension field to slice the data. How can I obtain the start and end dates for the slicer in the report? Currently, the report shows nothing, and there is no relationship between the slicer date field and the activity date fields. In the past, I used the date range concept, but the use case is different now.
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
8 | |
7 |