How to Get Equation from Graph in Google Sheets

Cody Schneider

Turning a graph in Google Sheets into a mathematical equation might sound like something you last did in a high school math class, but it’s an incredibly practical skill for forecasting business performance. Whether you want to predict next quarter’s sales or understand the relationship between your ad spend and revenue, this technique turns your historical data into a forward-looking tool. This article will guide you step-by-step through adding trendlines to your charts and displaying their equations, all within Google Sheets.

Why Get an Equation from a Graph in the First Place?

While a line chart or scatter plot is great for showing you where you’ve been, the equation behind that chart is what helps you predict where you’re going. It quantifies the relationship between your data points, giving you a model to forecast future outcomes.

Here are a few real-world scenarios where this is essential:

  • Sales Forecasting: By analyzing your sales data over the last 12 months, you can generate an equation to predict revenue for the upcoming quarter.

  • Marketing Campaign Analysis: You can model the relationship between your daily ad spend (your X variable) and the number of conversions (your Y variable) to see if your investment is paying off and forecast results at different budget levels.

  • Website Traffic Projections: Chart your monthly user growth and use the resulting equation to estimate when you might hit your next big milestone, like 100,000 monthly visitors.

  • Inventory Management: Predict future product demand based on past sales cycles, helping you stock up appropriately without overspending.

In short, getting the equation puts the "analytics" into your data visualization. It transforms a static report into a dynamic forecasting tool.

Step 1: Set Up Your Data for Analysis

Before you can get an equation from a graph, you need data that’s structured correctly. For trendlines and forecasting, you’ll typically work with two variables in what’s known as a scatter plot or line chart. You need an independent variable (the thing you control or that changes consistently, like time or ad spend) and a dependent variable (the result you measure, like revenue or traffic). This means two columns of data.

To follow along, let’s use a common marketing example: tracking monthly ad spend against resulting revenue.

Open a new Google Sheet and create a small table like this:

Month

Ad Spend ($)

Revenue ($)

January

1000

11500

February

1200

13000

March

1500

16000

April

1800

18200

May

2200

21800

June

2500

24500

Here, Ad Spend is our independent variable (X-axis), and Revenue is our dependent variable (Y-axis). We want to find out how Revenue changes as Ad Spend increases.

Creating the Chart

Now, let’s turn this data into a visual chart.

  1. Highlight the data range you want to plot. In our example, select the cells from "Ad Spend ($)" to the last revenue number (columns B and C). Do not include the "Month" column for this analysis.

  2. Go to the menu and click Insert > Chart.

  3. Google Sheets will probably default to a line chart or a column chart. For this kind of analysis, a Scatter chart is often best because it shows the relationship between two specific variables. In the Chart editor panel that appears on the right, under the “Setup” tab, find “Chart type” and select “Scatter chart”.

You should now see a graph with dots representing each data pair, clearly showing an upward trend: as ad spend increases, so does revenue. Now we’re ready to find the equation that defines that trend.

Step 2: Add a Trendline and Display The Equation

With your scatter chart created, finding the equation is just a few clicks away. We’ll do this using the trendline feature in the chart editor.

  1. Open the Chart Editor: If it’s not already open, simply double-click on your chart. This will bring up the sidebar with the "Setup" and "Customize" tabs.

  2. Navigate to the ‘Customize’ Tab: Click on the "Customize" tab in the editor.

  3. Expand the ‘Series’ Section: Scroll down and click on "Series" to expand its options. This is where you can format your data points, but it’s also where the trendline settings live.

  4. Check the ‘Trendline’ Box: Scroll down a bit further within the "Series" menu, and you’ll see a checkbox for "Trendline". Check it. A dotted or solid line will immediately appear on your chart, running through your data points. This is the "line of best fit" that mathematically summarizes the trend.

  5. Display the Equation: Now for the key step. Right below the "Trendline" checkbox, you’ll see a few more options. Find the dropdown menu for "Label". By default, it’s set to "None". Click on it and select "Use Equation".

Presto! The mathematical equation for your trendline will appear as a legend on the chart. For our sample data, you should see something like Revenue ($) = 9.07 * Ad Spend ($) + 2190.

Bonus Step: Check the R-Squared (R²) Value

Below the "Label" setting, you’ll find a checkbox for "Show R² value". It’s a good idea to check this too. The R-squared value, or "coefficient of determination," is a statistical measure of how well the trendline fits the data. It ranges from 0 to 1.

  • An R² of 1 means the line fits the data perfectly (all your data points are on the line).

  • An R² of 0 means the line doesn’t fit the data at all.

For our example, the R² value should be very high (something like 0.998), which tells us our linear model is a very good fit for this data. If you have a low R², your equation isn’t very reliable for making predictions.

Step 3: Choosing the Right Trendline Type

Google Sheets defaults to a "Linear" trendline, which works perfectly for data that moves in a straight line. But what if your data curves? In the "Series" section where you enabled the trendline, you can select different types of trendlines to better fit your data.

Here’s a quick guide to the most common types and when to use them:

  • Linear: This is the default and most common option. Use it when your data points appear to follow a straight line. Example: A steady increase in sales month after month.

  • Exponential: Use this when your data values are rising or falling at an increasingly rapid rate. The line will be a curve that gets steeper and steeper. Example: The growth of a viral video’s view count or subscribers to a rapidly growing channel.

  • Polynomial: This is for more complex data that has peaks and valleys – it curves more than once. You can even choose the "degree" of the polynomial to add more curves for a tighter fit (but be careful not to "overfit" your data). Example: Analyzing a product’s sales lifecycle, which grows, peaks, and then declines over time.

  • Logarithmic: This is useful for data that rises or falls quickly at first, but then levels out over time. It’s the opposite of an exponential curve. Example: The law of diminishing returns, like when your first few hundred dollars in ad spend bring in a lot of customers, but each additional hundred dollars brings in progressively fewer.

Experiment with different trendline types and use the R² value to help you decide which model best describes your data.

Step 4: Using Your Equation to Make Forecasts

Now that you have the equation — the most valuable part of this process — you can use it for forecasting. Let’s go back to our example showing Revenue = 9.07 * Ad Spend + 2190.

Suppose you plan to spend $3,000 on ads next month. You can now predict the expected revenue.

  1. Click on any empty cell in your Google Sheet.

  2. Type in the formula, replacing "Ad Spend" with your future value. You’d type: =9.07 * 3000 + 2190

  3. Press Enter. The result will be $29,400.

Based on your historical data, your model predicts that a $3,000 ad spend will generate approximately $29,400 in revenue. You can use this method to model different scenarios and set realistic goals for sales and marketing efforts. This is far more powerful than just looking at a line on a chart and guessing.

Final Thoughts

Getting an equation from a graph in Google Sheets is a simple but powerful way to move beyond just visualizing past data and toward actively forecasting the future. By adding a trendline, displaying its equation, and checking the R² value, you can create a reliable model to inform your sales targets, marketing budgets, and overall business strategy.

While mastering this technique in Google Sheets is incredibly useful, it often represents just one piece of a much larger analytics puzzle. The real challenge comes from pulling all your data — from Shopify, Google Analytics, Facebook Ads, and your CRM — into one place to analyze it together. That’s why we built Graphed. Our platform connects directly to all your data sources, letting you create dashboards and get forecasts just by asking questions in plain English instead of manually exporting CSVs and building charts. You can connect your marketing and sales apps in seconds and let AI build the reports that used to take you hours.