How to Extract Work Dates from Task Headcount Data in Excel
Question details
The user needs to extract dates from column headers based on task rows where daily headcount values are entered, filtering out days with no work.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Transforming a matrix of task names and date columns into a flat list of tasks and active work dates to support a Gantt chart.
- Observed behavior
- The data is organized with dates as horizontal column headers, making it difficult to directly isolate work and idle periods for project visualization.
Ensure your dataset is formatted as an official Excel Table (Ctrl+T) and verify that all column headers containing dates are formatted consistently so they can be accurately parsed.
Use Power Query to Unpivot Date Columns
Power Query is the most robust method to unpivot horizontal date headers into a vertical list, allowing you to easily filter out empty or zero-headcount dates.
Unpivoting transforms your matrix format into a tabular format, which is the ideal data structure for PivotTables and Gantt charts.
Select any cell in your data table, navigate to the Data tab, and click 'From Table/Range' to open the Power Query Editor.
Hold the Ctrl key and select the columns that do not contain dates, such as 'Task Name' or 'Task ID'.
Right-click the header of one of your selected static columns and choose 'Unpivot Other Columns'. This turns your date headers into a new 'Attribute' column and the headcounts into a 'Value' column.
Rename 'Attribute' to 'Date' and change its data type to Date. Rename 'Value' to 'Headcount'. Click the filter dropdown on the Headcount column and uncheck 'null' and '0' to remove idle periods.
Click 'Close & Load' on the Home tab to output your clean, vertical list of work dates to a new worksheet.

Extract Dates Using Excel Array Formulas
If you are using Excel 365, you can use dynamic array formulas to extract the corresponding dates without opening Power Query.
Manage Task Data and Build Charts Easily in WPS Spreadsheet
WPS Spreadsheet provides powerful dynamic array formulas, PivotTable capabilities, and charting tools to help you extract task work dates and visualize project timelines effortlessly.
- 1. Open your dataset: Launch WPS Spreadsheet and open your existing task and headcount file.
- 2. Extract the data: Utilize WPS Spreadsheet's dynamic lookup functions or PivotTable tools to isolate active dates where headcounts are recorded.
- 3. Create a Gantt chart: Highlight your extracted task dates, navigate to the Insert tab, and select a Stacked Bar chart to visualize your project's active and idle periods.

Frequently Asked Questions
Why do my unpivoted date headers appear as text or random numbers?
This occurs because Power Query initially interprets the unpivoted headers as generic text attributes. You can fix this by clicking the data type icon on the left side of the new column header and selecting 'Date' to convert them into standard calendar dates.
How do I ensure idle periods don't appear in my final Gantt chart?
When using Power Query, you must filter the newly created 'Values' (Headcount) column. Click the filter dropdown and uncheck '0' and '(null)'. This ensures only days with active work are passed to your chart data.
Can I automatically refresh the extracted dates when headcount numbers change?
Yes. If you used Power Query, right-click anywhere in your output table and select 'Refresh' to update the data. If you used dynamic array formulas like FILTER, the results will update instantly as soon as you change a headcount value.




