How to Get Dynamic Range in Charts in Google Sheets

Creating a dynamic range in charts is straightforward in Google Sheets. But first, what is a dynamic range?

A dynamic range ensures that when new rows or columns are added to the data used for creating a chart, the chart updates automatically. Let’s explore this with examples.

When plotting a chart in Google Sheets, you need to specify a data range. For instance, suppose you created a chart using the range A1:B2. If you later add another row, expanding the range to A1:B3, the chart should automatically include this new row if it’s dynamic.

This concept applies to columns as well. If you add data to C1:C3, the chart should include those values too.

Dynamic Row Ranges in Charts in Google Sheets

Dynamic ranges for rows are supported in Google Sheets. For example, even if your data range is set to A1:B2, Google Sheets will automatically detect newly added rows and adjust the chart accordingly.

If you don’t want the chart to include new rows, simply leave a blank row after the last row containing data before adding new entries.

Dynamic Column Ranges in Charts in Google Sheets

However, the above behavior doesn’t apply to columns. Consider the following sample data in A1:K4:

YearChinaIndiaUSAIndonesiaBrazilPakistanNigeriaBangladeshRussiaMexico
200012701053283212176138123131146103
201513761311322258208189182161146127
203014161528356295229245263186149148

If you add data to column L, expanding the range to A1:L4, the chart will still reference only A1:K4.

To make column ranges dynamic, you must select additional blank columns when creating the chart. Follow these steps:

  1. Select the range A1:M4, including two additional blank columns (or as many columns as needed).
  2. Click Insert > Chart.
  3. In the Chart Editor, under the Setup tab, select “Column” or “Bar” as the chart type, as the above data is well-suited for these chart types.
  4. Update the data range to A1:M4 if it hasn’t been set automatically.
Chart settings configured with extra blank columns for future data

Creating a Chart with Dynamic Ranges from Formula Outputs

Now, let’s explore dynamic ranges generated by formulas. We’ll use the same sample data as above, located in A1:K4, which lists the top 10 most populous countries by year.

Creating a Drop-down Menu with Years

  1. Navigate to cell N1.
  2. Click Insert > Drop-down.
  3. Enter the values 2000, 2015, 2030, and All.
  4. Click Done.

This will create a drop-down menu with an “All” option.

Filter Formula for the Dynamic Range

In cell O1, use this formula:

=ArrayFormula(
     IF(
        N1="All",
        A1:M,
        {{A1:M1}; FILTER(A2:M, A2:A=N1)}
     )
)

Explanation:

  • If “All” is selected in the drop-down, the formula returns the entire range A1:M (actual data with two empty columns for future country data if added in columns L and M).
  • Otherwise, it filters rows based on the selected year while preserving headers using curly braces ({{A1:M1};...}).

Creating the Chart

  1. Select the range O1:AA15 (the actual filtered data will be in O1:Y, with two empty columns reserved for potential future country data in columns Z and AA)
  2. Go to the Insert menu and select Chart.
  3. Choose “Column Chart” as the chart type.
  4. Modify the data range to O1:AA15.

Now, the chart dynamically adjusts as per the drop-down selection.

Example of dynamic row ranges in charts in Google Sheets

The above is actually an example of a dynamic row range in charts, even though we added additional columns. These columns currently do not contain any data.

Additional Tip: Filtering by Columns

Below is an example demonstrating how to visualize a dynamic column range in a chart.

To filter by columns (e.g., country names):

  1. Create a drop-down in N1 with all country names and an “All” option.
  2. Use this formula in O1:
=IF(N1="All", {A1:M}, {{A1:A}, FILTER(A1:M, A1:M1=N1)})

The steps for chart creation remain the same.

Example of dynamic column ranges in charts in Google Sheets

Example Sheet

Resources

We have seen examples of using dynamic ranges in charts in Google Sheets. Here are a few additional resources related to charts and filtering for charts.

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Marking Case-Sensitive Unique Values in Excel

Marking case-sensitive unique values provides several benefits compared to merely extracting them in an...

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Compare Two Tables for Differences in Excel

To compare two tables with similar data for differences, you can use the XLOOKUP...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

More like this

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

13 COMMENTS

  1. Prashanth,

    It was a great tutorial. I may have a bit more complex of a situation where I need my data and charts to be more dynamic than they are currently.

    I track dates of training completion and graph them by the department. As employees come and go, I add and delete rows of data, and I need my charts to be dynamic to respond to more or fewer employees within that department.

    I could use a little extra help beyond this tutorial.

    I’d be happy to allow you access to my sheet. But not sure how to do that in this setting.

    I also need to maintain confidentiality with the sheet. Would you be able to help me with my situation.?

    • Hi, Matt,

      Feel free to share the URL of the sheet below in your reply. I won’t publish that URL.
      You may replace personal info like real names, phone numbers, or email IDs with dummy info.
      Let’s try.

  2. Hi Prashanth,

    Great article! I am having trouble adding the Series label in the Setup tab. In your sample (Sheet3), the label is dynamic and cannot be changed. Where is that set up? If I copy past my data to your sheet is works but when I do one from the scratch I can’t do it. Also, in my case, even I manually insert the country name as a label, it does not appear as the label on the chart.

    Any idea?

    Many thanks

  3. Thanks for the info Prashanth. Very clever!

    I would like to be able to filter up to and including values. So for your example, if I selected 2015 for the filter, I would like the filter to select all rows up until that point (so 2000 and 2015); if I selected 2030 it would select 2000, 2015, 2030, etc.

    Any ideas on if that’s possible?

    • Hi, Matt,

      This is the formula you were talking about.

      =ArrayFormula(if(N1="All",A1:M,{{A1:M1};filter(A2:M,A2:A=N1)}))

      In this replace filter(A2:M,A2:A=N1) with array_constrain(A2:M4, match(N1,A2:A4),13)

      This way you can filter up to the row containing the selected value in the drop-down instead of only the row containing the selected value.

    • Hi, Jeff,

      There are two changes to switch the filtering from the “year” column to “country” row.

      1. Change the Data validation list (cell N1). In the field instead of years, use the below values.

      All,China,India,USA,Indonesia,Brazil,Pakistan,Nigeria,Bangaladesh,Russia,Mexico

      2. Then change the Filter formula in cell O1.

      =if(N1="All",{A1:M},{{A1:A},filter(A1:M,A1:M1=N1)})

      If you check the post again, in the end, you will see I’ve added a link to my sample chart sheet. In that open the “Sheet3” for the chart as per your requirement.

      Note: Inside the chart editor, under the “Setup”, enable “Switch rows/columns” to see how the chart adjusts.

      • Thank you so much, Prashanth! I tried to figure out it before asking, but this is very helpful. I appreciate your quick response and help!

  4. This is great information – thanks! I’ve got a slightly different challenge, and was wondering if you might have some insight.

    I have a tremendously long sheet (hourly data from several years), and I only want to chart the last n data points (maybe 500).

    How would you suggest I go about accomplishing that?

    • Hi, Andy,

      Here is one example.

      Range: E1:F (E1:F1 contain field labels)

      In this, I am filtering only the last 25% data. I mean the formula offsets the first 75% of rows.

      =query(E1:F,"Select E,F where E is not null offset "&round(counta(E1:E)*75%)-1)

      To get the last 500 data points, as per my example, the formula will be;

      =query(E1:F,"Select E,F where E is not null offset "&counta(E1:E)-501)

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.