How to Apply an Offset to a Chart in Excel

Cody Schneider

Creating a chart in Excel is easy, but making one that automatically shows the most recent data - like the last six months of sales - without you manually adjusting it every time? That’s a game-changer. This tutorial will walk you through exactly how to apply an offset to an Excel chart, giving you a dynamic and self-updating visual that focuses only on the data you care about.

Why Would You Offset a Chart in Excel?

In standard Excel charts, the data source is static. If your data range is A1:B12, your chart will always show data from A1:B12 unless you manually edit it. This becomes tedious when you’re constantly adding new data, like monthly sales figures or weekly web traffic, and only want to see the most recent trends.

An offset, or dynamic range, solves this problem. It creates a "moving window" of data that your chart references. This is perfect for:

  • Dashboards: Displaying key performance indicators (KPIs) for the last 7, 30, or 90 days.

  • Sales Reports: Automatically showing performance for the most recent quarter.

  • Financial Analysis: Visualizing a rolling 12-month revenue trend.

  • Project Management: Tracking progress over the last four weeks.

Instead of rebuilding or readjusting your reports every week or month, you can set it up once and let Excel do the heavy lifting. The key to making this work lies in combining two powerful Excel functions: OFFSET and COUNTA.

The Core Functions: OFFSET and COUNTA

Before building the chart, it’s important to understand the tools we’ll be using. These functions will work behind the scenes to tell your chart which data to display.

The OFFSET Function

The OFFSET function is designed to return a reference to a range that is a specified number of rows and columns from an initial cell or range. It sounds complex, but it's like giving Excel a starting point and directions to find the data you need.

The syntax looks like this:

=OFFSET(reference, rows, cols, [height], [width])

  • reference: This is your anchor or starting point. It’s typically the first cell of your full dataset (e.g., $A$1).

  • rows: How many rows to move down (positive number) or up (negative number) from the starting reference.

  • cols: How many columns to move right (positive) or left (negative) from the starting reference.

  • [height]: (Optional) The number of rows you want the returned range to have.

  • [width]: (Optional) The number of columns you want the returned range to have.

For our dynamic chart, we'll use all five arguments to define the exact height and location of our data "window."

The COUNTA Function

How do we tell OFFSET where to start? We need to know how much data we have in total. That's where COUNTA comes in. The COUNTA function simply counts the number of cells in a range that are not empty.

Its syntax is straightforward:

=COUNTA(value1, [value2], ...)

For example, =COUNTA(A:A) would count all the non-blank cells in column A. We will use this count to calculate how many rows to offset from the beginning of our data to find the starting point for our "last N months" window.

Step-by-Step Guide: Creating a Dynamic Chart with OFFSET

Let's build a chart that shows the last 'N' months of sales data, where 'N' can be changed on the fly. Follow these steps carefully.

Step 1: Set Up Your Data and Controls

First, organize your data in two columns. For this example, let's use "Month" (Column A) and "Sales" (Column B). Make sure you have a header row.

Next, we need a "control cell" that lets us define how many months to display. Find an empty space on your sheet (e.g., cell E2) and create a simple control panel:

  • In cell E1, type the label: Number of Months to Display

  • In cell E2, type a number, like 6. This will be our interactive control.

Your sheet should look something like this:

A

B

...

E

Month

Sales

Number of Months to Display

Jan-23

15200

6

Feb-23

18500

...

...

Step 2: Define Dynamic Ranges using Name Manager

This is where the magic happens. Instead of linking your chart to a static range like $B$2:$B$13, we'll link it to a named range that uses our OFFSET formula. A named range gives a human-readable name to a cell or cell range.

  1. Go to the Formulas tab on the ribbon and click Name Manager.

  2. In the Name Manager window, click New...

  3. Create two named ranges: one for sales data (Y-axis) and one for the months (X-axis).

Create the Named Range for Sales Data

  • In the Name: field, type ChartData.

  • Scope: Workbook

  • Refers to:

=OFFSET(Sheet1!$B$2, COUNTA(Sheet1!$B:$B)-Sheet1!$E$2-1, 0, Sheet1!$E$2, 1)

Explaination:

  • Starts at $B$2 (first sales data cell).

  • Moves down COUNTA(Sheet1!$B:$B)-Sheet1!$E$2-1 rows to the start of the last N months.

  • Height equals the value in E2.

  • Width is 1 column.

Create the Named Range for Month Labels

  • Click New... again.

  • Name it ChartLabels.

  • Refers to:

=OFFSET(Sheet1!$A$2, COUNTA(Sheet1!$A:$A)-Sheet1!$E$2-1, 0, Sheet1!$E$2, 1)

Now, click OK to save both and close the Name Manager.

Step 3: Create and Configure Your Chart

  1. Go to the Insert tab and choose the chart type you want (e.g., Line or Bar). Insert a blank chart.

  2. Right-click the chart and select Select Data.

  3. In the "Select Data Source" window, under Legend Entries (Series), click Add.

  4. In the "Edit Series" window:

    • Series name: click the header cell of your sales column (e.g., $B$1).

    • Series values: delete the existing content, then type:

=Sheet1!ChartData

(Ensure sheet name matches your sheet's name)

  1. Click OK.

  2. Under Horizontal (Category) Axis Labels, click Edit.

  3. Enter:

=Sheet1!ChartLabels

  1. Click OK twice.

Your chart now dynamically reflects the last N months of data based on the value in E2.

Step 4: Test Your Dynamic Chart

Change the number in cell E2 from 6 to 3, then to 12. The chart should instantly update to reflect the recent months accordingly.

Add new data to your table, the chart will automatically adjust, always showing the last period defined.

Common Issues and Best Practices

  • Blank Cells in Your Data: COUNTA counts all non-empty cells. If you have blank rows, the count will be off. Make sure your data is continuous.

  • Using Excel Tables: Turning your data into an official table (Ctrl+T) can help, but it doesn’t support the moving window feature easily.

  • Troubleshooting Named Ranges: If your chart doesn’t update correctly, check that your named ranges are referencing the correct cells and formulas.

Final Thoughts

You have now mastered a powerful charting technique in Excel. Using OFFSET, COUNTA, and named ranges, you can create dynamic dashboards that update automatically, saving time and increasing accuracy.

If you want an even faster way to generate live, dynamic dashboards from various data sources, consider using tools like Graphed. It connects platforms like Google Analytics, Shopify, or Salesforce, and produces real-time reports without writing formulas—freeing you to focus on analysis and decision-making.