Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Line Chart Formula: How to Plot Data

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

A line chart in Excel is not created by typing a formula into a cell. Instead, you build it from a chart that reads a range of cells. What people usually mean by "line chart formula" is a line chart drawn from cell references, often with one of Excel's line functions such as TREND or FORECAST.LINEAR supplying the plotted values. The shortest working method: put your categories in one column and your numbers in the next, select both columns, then choose Insert > Line or Area Chart > Line. Excel plots the second column as a series against the first.

Everything below assumes a reasonably current version of Excel on Windows or Mac. Labels can differ slightly by version, device and region.

What You'll Need

  • A workbook with your data laid out in columns or rows.
  • One column (or row) of labels or dates, and one or more columns of numeric values.
  • Numbers stored as real numbers, not as text with spaces, currency symbols typed into a text cell, or stray apostrophes.
  • No blank rows or columns inside the data range, because Excel may treat a gap as the end of the series.

Step-by-Step

  1. Lay out the data. Put your labels in column A, for example dates, months or product names. Put your values in column B and any additional series in columns C, D and so on. Give each column a header in row 1, such as "Month" and "Sales". Headers make the legend readable.
  2. Check the numbers are numbers. Select the value column and look at the status bar at the bottom of the window. If it shows a sum and an average, the cells are numeric. If it shows nothing useful, the numbers are likely stored as text. Convert them with Data > Text to Columns > Finish, or re-enter them without leading apostrophes.
  3. Select the data range. Drag from the top-left header cell to the bottom-right value, or click the first cell and hold Shift while clicking the last. If you have several series, select all of them at once.
  4. Insert the chart. Go to Insert > Line or Area Chart (on some versions, the ribbon just shows Line in the Charts group) and pick the first option, Line. For a single series against evenly spaced categories, this basic style is usually the right choice.
  5. Confirm which column is which. If Excel plotted your labels as a series, select the chart, choose Chart Design > Select Data, and set the correct Legend Entries (Series) and Horizontal (Category) Axis Labels ranges by hand. On Mac this dialog may appear as Chart Design > Select Data with the same fields.
  6. Tidy the axes. Right-click the value axis and choose Format Axis to set the minimum, maximum and major unit. This matters when Excel starts the axis at zero and flattens a series that only varies between, say, 40 and 46.
  7. Add the chart title and labels. Use the + button beside the chart, or Chart Design > Add Chart Element, to add a title, axis titles and a legend. Turn the legend off for a single-series chart; the title already says what is plotted.
  8. Use a formula for the plotted series when needed. To chart a calculated trend line rather than the raw observations, put the output of a line function in an empty column. For example, if observations are in B2:B13 and periods in A2:A13, you can write =TREND($B$2:$B$13,$A$2:$A$13,A2) in C2 and fill it down. The values in C then become a second series on the chart. TREND fits a straight line by least squares; for a single prediction use =FORECAST.LINEAR(x, known_ys, known_xs).
  9. Keep the chart live. Because the chart points at a range, adding a new row at the end of the source data does not always extend it. Right-click the chart and choose Select Data to widen the range, or convert your source data to a table with Insert > Table first so the range grows automatically.

Common Mistakes

  • Confusing a trendline with a formula. A chart trendline describes the data but does not put values in cells. Use TREND or FORECAST.LINEAR when you need the numbers in the grid.
  • Plotting dates as categories. If dates are stored as text, the line will space them evenly rather than by real time gaps. Convert text dates with Text to Columns and reformat.
  • Missing headers. Without a header, Excel may treat the first data row as the series name.
  • Choosing a stacked line chart by accident. Stacked lines show cumulative totals, not separate values, which is rarely what a "line chart" means.
  • Hard-coded numbers in the formula. Typing numbers directly into TREND instead of referencing ranges stops the chart updating when the source changes.

Tips

  • Press Alt+F1 on Windows to insert a default chart from the selected range instantly; F11 creates it on its own chart sheet.
  • Right-click a data series and choose Add Trendline to overlay a fitted line quickly, then tick Display Equation on chart to see its slope and intercept.
  • Use markers on a line chart when points are widely spaced and you want to show where the actual readings fall.
  • Name your source ranges with Formulas > Define Name to make TREND and FORECAST.LINEAR formulas easier to read.
  • Keep a separate chart sheet for dashboards; Move Chart in the chart's right-click menu does this without copying data.

Troubleshooting

The line is flat or jagged at zero. One or more cells are text or blank. Clean the data and check the status bar.

Labels appear as 1, 2, 3 on the axis. Excel is not using your label column. Open Select Data and set the category axis labels range explicitly.

The chart has the wrong series. Your selection included an extra column. Edit the range in Select Data or drag the range handles on the worksheet.

A TREND or FORECAST.LINEAR formula returns an error. Check that the known_xs and known_ys ranges are the same size. A #N/A from mismatched ranges is the usual cause.

New rows do not appear. Widen the range in Select Data, or convert the source to a table and rebuild the chart.

The chart looks broken after editing. Select it and press Delete, then rebuild from a clean, contiguous range. Chart objects do not repair themselves reliably.

Frequently Asked Questions

Is there a formula that creates a chart?

No. Charts are objects placed from the ribbon, not cell formulas. Formulas can supply the values a chart reads, through functions such as TREND or a plain reference like =B2.

How do I plot two lines on one chart?

Select both value columns together with their labels and insert a line chart. Excel plots each column as a separate series in the same chart.

Can I chart a running total?

Yes. Add a helper column with a cumulative formula such as =SUM($B$2:B2), fill it down, and plot that column instead of the raw values.

What is the difference between TREND and FORECAST.LINEAR?

Both fit a straight line. TREND returns a series of fitted values for many x values; FORECAST.LINEAR returns a single predicted y for one x. FORECAST.LINEAR replaces the older FORECAST function.

Why does my date axis show gaps?

Excel may be using a text axis instead of a date axis. Right-click the category axis, choose Format Axis, and select Date axis if that option is offered.