Google Sheets: Exclude X-Axis Labels If Y-Axis Values Are 0 or Blank

Published on

In Google Sheets, charts don’t offer a built-in option to hide or exclude x-axis labels when the corresponding y-axis values are 0 or blank. This can make your charts look cluttered or misleading—especially when visualizing clean, meaningful data.

Thankfully, there are a few workarounds that help you exclude x-axis labels if y-axis values are 0 or blank in Google Sheets charts. In this guide, I’ll walk you through three practical methods:

  • Using the Filter menu
  • Using a Slicer (recommended)
  • Using the QUERY function

When Would You Need This?

Say you have a chart showing daily sales volume, and some days—like weekends or holidays—have 0 sales or no data at all. Instead of displaying all dates on the x-axis regardless of activity, you’d prefer to hide those inactive days to keep the chart cleaner and more focused.

The most basic way to exclude x-axis labels tied to blank or zero values is by manually hiding the rows in your dataset. This works with most chart types (Line, Column, Pie, Candlestick, etc.).

Manually hiding rows in Google Sheets to remove x-axis labels with zero or blank values in a chart

Limitations:

  • Time-consuming if your dataset is large.
  • Easy to accidentally hide rows you didn’t mean to.
  • Doesn’t scale well with dynamic data.

I suggest skipping this method if you’re looking for something reliable and scalable. Instead, try the next three.

Method 2: Use the Filter Menu to Hide 0 or Blank Y-Axis Values

This is a quick and user-friendly way to hide x-axis labels based on their y-values.

Steps:

  1. Select your range, including some extra blank rows if you expect future entries (e.g., A2:B17 even if data is only up to B9).
  2. Go to Data > Create a filter.
  3. In the filter icon for your Y-axis column (e.g., “Volume”), click the dropdown and deselect both “Blanks” and “0” — or just one of them, depending on whether you want to hide empty cells, zero values, or both.
  4. Click OK.
Using the filter menu in Google Sheets to exclude 0 and blank y-axis values from the chart

Now your chart will exclude x-axis labels where the y-axis values are 0 or blank.

Pros:

  • Easy to set up.
  • Works even if the chart is moved to its own sheet.

Cons:

  • You’ll need to reapply the filter after editing or adding rows with 0 or blank values—just open the filter dropdown and click OK to refresh it.

A Slicer is a floating filter that gives you control over what data appears in your chart—without modifying your original dataset.

Keep your data in one sheet (e.g., “Sheet1”) and your chart and slicer in another (e.g., “Sheet2”).

Why Use a Separate Sheet for Slicers?

When the chart and slicer are on the same sheet as the source data, applying slicer filters can also hide rows in the data, which makes it harder to edit or maintain.

By moving the chart and slicer to a separate sheet:

  • Your original data remains untouched and fully visible.
  • The slicer filters apply only to the chart, not to the source data.

Steps:

1. Copy your chart from Sheet1 and paste it into Sheet2.

2. In Sheet2, go to Data > Add a slicer.

3. In the Slicer settings:

  • Set the data range to match your source.
  • Choose your y-axis column (e.g., “Volume”).
Slicer settings panel in Google Sheets showing how to exclude x-axis labels if y-axis values are 0 or blank

4. On the slicer, uncheck ‘Blanks’ and ‘0’.

Google Sheets slicer used to filter out zero and blank y-values from chart x-axis labels

Your chart will now update dynamically to exclude x-axis labels with 0 or blank y-values.

Pros:

  • Cleaner control: filters only apply to the chart, not your data.
  • Easier to maintain over time.

Cons:

  • The slicer won’t work if you move the chart to its own sheet using the “Move to own sheet” option (from the chart’s three-dot menu).
  • If you update the source data and add new rows with 0 or blank values, the slicer won’t automatically filter them out. You’ll need to open the slicer dropdown and simply click OK again to refresh the filter and exclude the new values.

Method 4: Use the QUERY Function to Filter Chart Data

If you prefer a formula-based solution, use the QUERY function to create a filtered version of your data and base your chart on that.

Example:

=QUERY(Sheet1!A2:B, "SELECT A, B WHERE B > 0", 1)

This excludes any row where the y-axis value (column B) is 0 or blank.

Pros:

  • Fully automated once set up.
  • Keeps your main dataset untouched.

Cons:

  • You’re creating a new data range just for the chart.

Conclusion

Google Sheets doesn’t give you an out-of-the-box way to hide x-axis labels based on y-values, but with a little creativity, it’s absolutely possible.

If you’re looking for a quick fix, the Filter menu might be enough. But if you want a more reliable and dynamic setup, I recommend using a Slicer or a QUERY-based solution.

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Top Discussions

More like this

Pivot Table Formatting, Output & Special Behavior in Google Sheets

Pivot Tables in Google Sheets are powerful—but they can get tricky once you move...

Pivot Table Calculations & Advanced Metrics in Google Sheets

When it comes to built-in tools for data analysis and visualization in Google Sheets,...

Google Sheets Pivot Table Tutorial: Basics, Setup, and Date Grouping

The easiest way to summarize, analyze, and report data in Google Sheets is by...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.