A pivot table does not have a built-in date-range filter by default, but you can easily add one by converting date columns into a slicer or using Excel’s filter dropdowns. The fastest method involves sorting dates first, then applying a filter to show only the desired range. Below is the complete, accurate process for Excel for Microsoft 365, Excel 2019, and Excel 2016, with platform-specific notes where relevant.
What You'll Need
- A workbook with a pivot table containing a date column (e.g., sales dates, order dates, or timestamps).
- Excel for Microsoft 365, Excel 2016, or Excel 2019 (methods vary slightly for older versions).
- A column or row in your source data that stores dates in a recognizable format (e.g., MM/DD/YYYY, DD-MM-YYYY). If dates are stored as text, you must convert them to proper date format first.
- Basic familiarity with pivot tables—knowing how to add fields to rows, values, or filters.
Step-by-Step
- Prepare your data for dates:
- Open your Excel workbook. If your date column is formatted as text, right-click the column header, select Format Cells, go to the Number tab, and choose Date. Click OK. This ensures Excel recognizes the dates correctly.
- Sort the date column in ascending order (earliest to latest). Select the column, then click the Sort A to Z button (▼) in the Data tab or use Data > Sort > Sort A to Z. If the dates are already sorted, skip this step.
- Set up the pivot table (if not already created):
- Select your data range, then go to the Insert tab and click PivotTable. In the dialog box, ensure the data range is correct and click OK.
- Drag your date column to the Rows area of the pivot table layout. If you want to filter by date ranges later, drag another column (e.g., product name, region) to the Values or Columns area.
- Add a filter for the date column:
- Click the dropdown arrow (▼) in the pivot table’s date field header (under ROWS or COLUMNS, depending on placement).
- In the filter list, you’ll see all unique dates. To filter a range, you’ll need to use the Filter > Between option (or Filter > (No Filter) > Between if the option isn’t immediately visible).
- Select Between and enter your start and end dates in the dialog box (e.g., 01/01/2024 and 12/31/2024). Click OK. The pivot table will now show only data within that date range.
Note: If the Between option does not appear, your dates might be stored as text or not properly formatted. Recheck Step 1.
- Create a slicer for interactive filtering (optional but recommended):
- Click anywhere in your pivot table to activate it. Go to the Analyze tab in the PivotTable Tools section (if this tab is missing, your Excel version might not support slicers—see Troubleshooting for alternatives).
- In the Filters group, click Insert Slicer. A dialog box will appear.
- Check the box next to your date column and click OK. A slicer will appear above your pivot table or to the side.
- Click and drag the slicer’s date range to select a custom date filter. For example, to show only dates between January 1 and March 31, 2024, click the date range’s start and drag to the end date.
Note for older Excel versions: If you don’t see the Analyze tab, you can use the Filter dropdown method from Step 3 instead. Slicers are available in Excel 2013 and later.
- Save the pivot table with your filter settings (optional):
- To refresh the pivot table with new data, right-click any cell in the pivot table and select Refresh. If you’ve used a slicer or date range filter, this will update automatically when the underlying data changes.
- If you want to permanently save the date range filter, you must recreate the pivot table with the filter applied each time (Excel does not store filter settings in the pivot table file itself).
Common Mistakes
Here are the most frequent errors users make when adding a date range filter to a pivot table:
- Dates formatted as text: If your date column is stored as text (e.g., 01/01/2024 appears as “01/01/2024”), Excel will not recognize it as a date. The filter will only work if you convert it to a proper date format first (see Step 1).
- Using relative or absolute references incorrectly: If you copy a pivot table with a date filter to another sheet, the filter may break. Always recreate the pivot table on the new sheet.
- Assuming the filter applies to all pivot tables: Each pivot table is independent. If you filter one pivot table, it does not affect others in the same workbook.
- Ignoring blank cells in the date column: If your data has blank cells where dates should be, the pivot table may miscount or fail to filter correctly. Clean your data first by removing or replacing blanks.
- Not sorting dates before filtering: If dates are unsorted, the Between filter may not work as expected. Always sort dates in ascending order before applying a range filter.
Tips
Follow these best practices to make date range filtering smoother:
- Use consistent date formats: Ensure all dates in your dataset follow the same format (e.g., MM/DD/YYYY). Mixing formats (e.g., DD-MM-YYYY and MM/DD/YYYY) can cause errors.
- Leverage slicers for interactivity: Slicers allow users to dynamically adjust date ranges without manually entering values. They’re especially useful in dashboards or reports shared with others.
- Combine date filters with other fields: For example, filter by both date range and product category. Drag your product column to the pivot table’s Filters area and use its dropdown to narrow results further.
- Use Excel’s GETPIVOTDATA function for custom filters: If you need to create a dynamic date range filter outside a pivot table (e.g., in a spreadsheet cell), use this function to pull data based on user-selected dates.
- Test with a small dataset: Before applying date filters to a large pivot table, test with a subset of data to ensure the filter works as intended.
- Update your data source: If your pivot table relies on external data (e.g., a connected table or external file), refresh the connection regularly to avoid stale date ranges.
Troubleshooting
If your date range filter is not working, try these steps in order:
- Verify date format: Right-click the date column header and check the format. If it reads as General or Text, convert it to a date format (see Step 1).
- Check for blank or invalid dates: Open your source data and look for cells with #N/A, 0, or blank values where dates should be. Replace or remove these values.
- Sort the date column: If dates are not in order, the Between filter may not function. Select the column and sort it ascending (A to Z) before filtering.
- Recalculate the pivot table: Right-click anywhere in the pivot table and select Refresh to update the data. If the filter still doesn’t work, recreate the pivot table.
- Use a slicer instead: If the filter dropdown is problematic, insert a slicer (Step 4) for more reliable date range selection.
- Check for hidden or merged cells: If your date column has merged cells or hidden rows/columns, the pivot table may misinterpret the data. Unmerge and unhide cells as needed.
- Test with a new pivot table: Create a fresh pivot table from the same data to rule out corruption. Copy your original pivot table’s layout (e.g., fields in Rows/Values) and rebuild it.
- Update Excel: If you’re using an older version of Excel (e.g., 2010 or earlier), some features like slicers or advanced filtering may not work. Consider upgrading or using alternatives like Power Query for date filtering.
- Check for circular references or formulas: If your date column contains formulas (e.g., =TODAY()), the pivot table may not recognize it as a static date. Replace formulas with hardcoded dates if possible.
If that did not work: If none of the above steps resolve the issue, your data may have structural problems (e.g., dates stored as numbers or strings without formatting). In this case, consider:
- Using Power Query to clean and transform your data before creating the pivot table. Power Query can convert text dates to proper date formats automatically.
- Contacting Excel support or consulting a tutorial on Power Pivot if your data is complex (e.g., multilevel date hierarchies).
Frequently Asked Questions
How do I filter a pivot table by a specific month?
You can filter by month in two ways:
- Use the Between filter in the pivot table’s date column dropdown and enter the start and end dates of the month (e.g., 01/01/2024 and 01/31/2024).
- For a more precise method, create a calculated field in the pivot table that extracts the month name or number. Right-click the pivot table, select Field Settings, then Show Values As > Calculated Field. Enter a formula like =MONTH([@Date]) to filter by month number.
Can I filter a pivot table by dates from another sheet?
Yes, but with limitations. Pivot tables can only filter data from their own source table or range. If your dates are on another sheet, you must:
- Create a Table on the second sheet (insert a blank row, then select the data and press Ctrl + T to convert it).
- Use Power Query to merge the tables and create a unified dataset, then build your pivot table from the combined data.
- Avoid linking pivot tables directly to multiple sheets, as this can cause errors or inconsistent filters.
Why does my pivot table filter show "No matching records" when I apply a date range?
This error typically occurs due to one of the following:
- Dates are not recognized as dates: If your date column is formatted as text, Excel cannot match the filter. Convert it to a date format first.
- The date range is outside the data’s range: For example, if your data only goes up to December 2023, filtering for January 2024 will return no results. Double-check your date range.
- Blank cells in the date column: If your data has blanks where dates should be, the filter may exclude those rows. Clean your data or use the Between filter to include blanks explicitly.
- The pivot table is not refreshed: Right-click the pivot table and select Refresh to ensure it’s using the latest data.
How do I filter a pivot table by dates in a different format (e.g., DD-MM-YYYY vs. MM/DD/YYYY)?
Excel automatically detects the date format in your data, but if it’s inconsistent, you’ll need to:
- Convert all dates to the same format: Use Data > Text to Columns to split and reformat dates uniformly. For example, if your dates are stored as DD-MM-YYYY but Excel interprets them as MM/DD/YYYY, select the column, go to Data > Text to Columns, choose Delimited, and split by spaces or dashes. Then manually reformat them.
- Use a helper column: Add a new column next to your date data and use a formula like =DATEVALUE(SUBSTITUTE(A2, "/", "-")) to standardize the format. Then use this helper column in your pivot table.
- Check regional settings: If you’re working with international data, your system’s regional settings (e.g., Control Panel > Clock, Language, and Region on Windows) may affect how dates are parsed. Ensure your system uses the correct date format for your data.
Can I filter a pivot table by dates using a cell reference (e.g., dynamic dates in another cell)?
Yes, but you’ll need to use a combination of pivot table filters and Excel functions. Here’s how:
- Enter your start and end dates in separate cells (e.g., A1 and A2).
- In the pivot table’s date column dropdown, select Between. Instead of typing dates, click the dropdown arrow next to Value 1 or Value 2 and choose Cell Reference. Select A1 for the start date and A2 for the end date.
- If the pivot table does not support cell references natively, use a VBA macro or Power Query to dynamically update the filter based on cells.
- For advanced users, you can create a custom function or use OFFSET to pull dates from another sheet or range.
Why does my slicer disappear when I close and reopen the workbook?
Slicers are not saved with the pivot table itself—they are part of the workbook’s structure. To ensure they reappear:
- Save the workbook in Excel’s default format (.xlsm) if you’re using macros. However, if you’re not using VBA, slicers should still appear when you reopen the workbook.
- Check the PivotTable Analyze tab for the Insert Slicer button. If it’s missing, the slicer may have been accidentally deleted. Reinsert it (see Step 4).
- If the slicer still doesn’t appear, recreate it: Right-click the pivot table, select PivotTable Options, go to the Layout & Format tab, and ensure the Show slicers option is checked.
- For shared workbooks, slicers may not display for others unless they are added manually. If you’re collaborating, ask team members to reinsert slicers on their copies.