How to Create a Year Selector to Show or Hide Excel Chart Data
Question details
The user wants to dynamically switch the data displayed in an Excel chart between multiple years using a selector cell, instead of manually adjusting the chart's data source settings.

- Product
- Spreadsheet
- Device & OS
- not provided
- Scenario
- Creating dynamic charts for yearly data comparison or reporting.
- Observed behavior
- The user needs a method to dynamically update chart visuals based on a selected year value without altering chart configurations manually.
Ensure your dataset is organized cleanly in columns or rows by year, and identify a blank cell outside your main data area to serve as the year selector input.
Use Helper Formulas and a Selector Cell
The most reliable method is to use a helper column that pulls data for the selected year using logical formulas like IF or XLOOKUP, and linking your chart to this helper column.
By pointing your chart to a dynamic helper column instead of the raw data, the chart automatically updates whenever the selector cell changes. This works seamlessly for line charts, bar charts, and interactive dashboards.
Choose a blank cell (e.g., D1) and type the year you want to view initially, such as 2024 or 2025. You can also use Data Validation to make this a drop-down list.
Next to your data labels, add a new column for the dynamic data. If your 2024 data is in column A and 2025 data is in column B, enter `=IF($D$1=2024,A1,B1)` in the first data row.
Drag the fill handle down to apply this formula to all rows in your dataset. The column will now display the data matching the year entered in cell D1.
Select your category labels and the new helper column. Go to the Insert tab, select your preferred chart type (like a Line Chart), and generate the graph. Change the year in D1 to see the chart update automatically.

Easily Create Dynamic Charts with WPS Office
WPS Spreadsheet fully supports advanced logical formulas and dynamic charting, allowing you to build interactive dashboards and year-selector charts effortlessly. It provides an intuitive interface and high compatibility with standard spreadsheet formats.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your workbook containing the yearly data.
- 2. Add a Drop-down List: Select your selector cell, go to Data > Data Validation, and create a drop-down list of years.
- 3. Use Helper Formulas: Apply IF or XLOOKUP in a helper column to dynamically pull the selected year's data based on the drop-down.
- 4. Create Your Chart: Highlight the dynamic column, go to Insert > Chart, and switch years from the drop-down to see real-time chart updates.

Frequently Asked Questions
How can I make the selector cell a drop-down menu?
Select the cell you want to use as the year selector, go to the Data tab, and click Data Validation. Choose 'List' under the Allow criteria, and type your years separated by commas (e.g., 2023, 2024, 2025) or highlight the cells containing your year headers.
What if the data range varies in length for different years?
If your data ranges have different lengths, formatting your raw data as an Excel Table (Ctrl+T) or using Named Dynamic Ranges with the OFFSET and COUNTA functions will ensure the chart automatically adjusts to fit the visible data without plotting empty space.
Can I use the CHOOSE formula for a year selector?
Yes. If you assign an index number (1, 2, 3...) instead of the actual year (2024, 2025...) in the selector cell, you can use the CHOOSE function. For example, `=CHOOSE($D$1, A2, B2, C2)` will return data from column A if D1 is 1, column B if 2, and so on.
Why is my chart displaying empty spaces when I switch years?
This happens if your helper formula returns empty text ("") or zeroes for blank cells, which the chart still plots as data points. To fix this, wrap your formula in an IF statement to return `#N/A` using the `NA()` function when a cell is blank. Line charts automatically ignore `#N/A` errors.




