ECON 290 · Economic Data and Computing

Spreadsheets for Economic Analysis

Learn to organize data in rows and columns, write formulas for growth and averages, and avoid common spreadsheet traps.

Key takeaways

  • A good sheet keeps one observation per row and one variable per column, with a clear header on top.
  • Formulas keep your work live: change an input and every answer updates.
  • Percent change is (new − old) ÷ old, and a spreadsheet can compute it for a whole column at once.
  • Absolute references, written with dollar signs, keep a formula pointing at the same cell when you copy it.
  • Most spreadsheet errors come from hidden typed-in numbers, mixed units and copy-and-paste slips, not from hard math.

A spreadsheet looks like a plain grid of boxes. Yet this grid has been behind countless budgets, forecasts and research papers, and it is where many working economists spend a large part of their day. It is also where some costly mistakes have happened, because a grid makes it easy to type a wrong number and hard to see it afterward.

Picture Maya again, the owner of the smoothie cart in the invented town of Brightwater. For a year she has scribbled sales in a notebook. Now she wants to know whether sales are growing, which month is best, and whether next summer will beat this one. A spreadsheet can answer all three in minutes, if she sets it up well. This lesson shows how.

Set up the grid the right way

A spreadsheet is a grid of cells. Columns have letters (A, B, C) and rows have numbers (1, 2, 3), so a cell has an address like B3. The first rule of good work is about layout.

  • One row per observation. If you track Maya's sales by month, each month is one row.
  • One column per variable. One column for the month, one for sales, one for costs.
  • A header in row 1. Plain names like "Month" and "Sales ($)" so you remember what each column holds.
  • One unit per column. Do not mix dollars and thousands of dollars in the same column.
  • Nothing else in the data block. Notes and totals go beside or below, not in the middle.

Data kept this way is called tidy, and it matters because almost every tool, from charts to the code in the programming lesson, expects it. Data from agencies, described in the first lesson of the course, often arrives as downloadable tables you can open directly.

Formulas: let the sheet do the arithmetic

A formula starts with an equals sign. It can use numbers, cell addresses and built-in functions. If cell B2 holds 2,000 and B3 holds 2,200, then:

=B2+B3        adds the two cells, giving 4,200
=SUM(B2:B5)   adds every cell from B2 to B5
=AVERAGE(B2:B5)  gives the mean of those cells
=MAX(B2:B5)   finds the largest value

The great virtue is that formulas stay live. If Maya fixes a typo in B3, every total and average that uses it changes by itself. A number typed by hand would never update, which is why the first rule of spreadsheet hygiene is: if a value can be calculated, calculate it.

Other functions you will meet often are MIN, COUNT, ROUND, and IF, which picks one result or another depending on a test. The exact function names are the same in most spreadsheet programs, but check your program's help for small differences.

A worked example: Maya's first four months

Here are Maya's sales for four months, in dollars. They are invented numbers.

Month Sales ($)
Jan 2,000
Feb 2,200
Mar 2,750
Apr 2,640

Put the months in A2:A5 and the sales in B2:B5. Now compute three things.

Total and average.

Total = 2,000 + 2,200 + 2,750 + 2,640 = 9,590
Average = 9,590 ÷ 4 = 2,397.50

In the sheet: =SUM(B2:B5) and =AVERAGE(B2:B5).

Percent change from the previous month. In cell C3, type =(B3-B2)/B2 and copy it down. The sheet adjusts the addresses as it copies.

Feb: (2,200 − 2,000) ÷ 2,000 = 0.10, or +10%
Mar: (2,750 − 2,200) ÷ 2,200 = 0.25, or +25%
Apr: (2,640 − 2,750) ÷ 2,750 = −0.04, or −4%

Format column C as a percent so the sheet shows 10%, 25% and −4%.

Best month. =MAX(B2:B5) returns 2,750, and a lookup function can tell you it was March.

Maya's sales sheet, as numbers
Maya's Smoothies Monthly Sales January to April Sales by month January $2,000 February $2,200 March $2,750 April $2,640 Four-month total $9,590 Maya's Smoothies Monthly Sales January to April Sales by month January $2,000 February $2,200 March $2,750 April $2,640 Four-month total $9,590

The total comes from =SUM(B2:B5). The average is 9,590 ÷ 4 = 2,397.50. Example with made-up numbers.

Percent change
Change = (New − Old) ÷ Old Change = Percent change How much the value grew, as a share of where it started (New − Old) = The gap Positive for growth, negative for a drop Old = The starting value Dividing by this makes the change a share Change = (New − Old) ÷ Old Change = Percent change How much the value grew, as a share of where it started (New − Old) = The gap Positive for growth, negative for a drop Old = The starting value Dividing by this makes the change a share

Copy this down a column to get a growth rate for every row.

Absolute references: keep a cell pinned

Say Maya's fruit costs about 40 percent of sales. She types 0.40 in cell E1 and wants a cost estimate beside every month. In C2 she writes =B2*E1 and copies it down. The first row works. But in C3 the formula becomes =B3*E2, and E2 is empty. The result is zero or an error.

When you copy a formula, the sheet shifts every address. To stop an address from moving, anchor it with dollar signs: =B2*$E$1. Now each copy keeps pointing at E1.

Jan cost = 2,000 × 0.40 = 800
Feb cost = 2,200 × 0.40 = 880
Mar cost = 2,750 × 0.40 = 1,100
Apr cost = 2,640 × 0.40 = 1,056

This also shows a good habit: put assumptions such as the 40 percent in a labeled cell, not inside formulas. Then if costs change to 45 percent, Maya edits one cell and the whole sheet updates. Hidden numbers inside formulas are called hard-coded, and they are a common source of error because nobody remembers them.

Sorting, filtering and pivot tables

Three more tools turn a long table into insight.

  • Sort reorders rows, for example from highest to lowest sales. Always sort the whole block, not one column, or you will scramble your rows.
  • Filter hides rows that do not meet a test, such as "only months above $2,500."
  • Pivot table summarizes a big table by groups. If Maya recorded each sale with a date and a flavor, a pivot table could total sales by flavor and by month without any formula writing.

Economists use pivots all the time. With a table of jobs by state and industry, one pivot gives jobs by industry nationwide, and another gives jobs by state. For cleaning and joining tables from different places, see cleaning and merging data.

Maya's sales, January to April
Sales ($) Sales March peak Month number Sales ($) Sales March peak Month number

A line chart is a quick check that your numbers look sensible.

Monthly numbers bounce around. A handy way to see the trend is a moving average, which averages the latest few values and then slides forward one step. Using Maya's four months, a three-month moving average starts in March.

March: (2,000 + 2,200 + 2,750) ÷ 3 = 6,950 ÷ 3 = 2,316.67
April: (2,200 + 2,750 + 2,640) ÷ 3 = 7,590 ÷ 3 = 2,530

In the sheet, type =AVERAGE(B2:B4) in C4 and copy it down. The relative addresses slide along by themselves, which is exactly the behavior you want here. The smoothed line is calmer than the raw one, and it shows that sales are rising overall even though April dipped from March. The full idea, with growth rates, is in time series basics.

Checking your own work

Good analysts assume they made a mistake and then go looking for it. Four quick checks catch most problems.

  1. Add up two ways. Total the rows, then total the columns. If a grid has both, the two grand totals must match.
  2. Test with easy numbers. Replace your data with 1, 2, 3 and see whether the formulas give the answers you can work out in your head.
  3. Look at the extremes. Sort by each column and read the top and bottom rows. A sales figure of 27,500 among values near 2,750 is probably a typo.
  4. Keep the raw data untouched. Copy it to a new sheet before you clean it, and do your work in formulas that point back to the original. Then you can always see what changed. This is also the first rule of reproducible work.

A written note on the sheet, saying where the data came from and the date you downloaded it, will help you, and everyone who inherits your file, a year from now.

Real versus nominal in a sheet

A spreadsheet is a good place to turn nominal numbers into real ones. Suppose a price index is 100 in January and 105 in April (invented). Maya's April sales of $2,640 in January's prices are:

Real April sales = 2,640 ÷ 105 × 100 = 2,514.29 (rounded)

In the sheet this is =B5/D5*100 where column D holds the index. April's nominal sales fell 4 percent from March. Real sales fell too, and by a bit more, because prices rose. Keeping a column for the index lets you recompute every row at once.

Common mistake: errors you cannot see

Spreadsheet errors are famous because they hide. Watch for these.

  1. Typed numbers inside formulas. =B2*0.4 hides the 0.4. Put it in a cell.
  2. Mixed units. One row in dollars and the next in thousands will not announce itself.
  3. A range that misses a row. If you add a new month below the data, =SUM(B2:B5) will not include it. Use ranges that cover the new rows, or convert the data into a table that grows.
  4. Copying values over formulas. A pasted number looks the same but no longer updates.
  5. Text that looks like numbers. A cell holding "2,000" as text will be ignored by SUM.
  6. Sorting only part of the data. This breaks the link between columns.

A simple defense is to check totals two ways. If the sum of the monthly figures does not match the yearly total from a different source, find out why before you go on.

Words to know

Cell one box in a spreadsheet, named by its column letter and row number, like B3.

Formula an instruction in a cell, beginning with an equals sign, that calculates a value.

Function a built-in formula tool, such as SUM or AVERAGE.

Absolute reference a cell address with dollar signs, such as $E$1, that does not change when the formula is copied.

Hard-coded a number typed directly into a formula instead of kept in a labeled cell.

Pivot table a tool that summarizes a table by groups.

Tidy data data with one observation per row and one variable per column.

Check yourself

  1. What does the header row do, and why should each column hold one unit?
  2. Sales in cells B2 to B5 are 500, 600, 700 and 800. What do =SUM(B2:B5) and =AVERAGE(B2:B5) give?
  3. Sales rise from 800 to 920. What formula gives the percent change, and what is the result?
  4. A cost rate of 25 percent is in cell E1. Write a formula for the cost of sales in B2 that can be copied down, and say why dollar signs are needed.
  5. Explain why a hard-coded number inside a formula is risky.
  6. A price index goes from 100 to 110 and nominal sales from 1,000 to 1,100. What happens to real sales?
Show the answers
  1. The header names each variable so you remember what it holds, and one unit per column keeps rows comparable and sums meaningful.
  2. SUM = 500 + 600 + 700 + 800 = 2,600; AVERAGE = 2,600 ÷ 4 = 650.
  3. =(920-800)/800 gives 120 ÷ 800 = 0.15, or +15 percent.
  4. =B2*$E$1; the dollar signs pin E1 so each copy still points at the 25 percent cell.
  5. Nobody can see or easily update it, so the sheet can go wrong silently when the number should change.
  6. Real sales = 1,100 ÷ 110 × 100 = 1,000, the same as before, so nothing real changed even though nominal sales rose 10 percent.

A free self-study program written for 4Economics with AI writing tools and not reviewed line by line by a person. It is not an accredited degree and awards no credit. Check anything you rely on against a textbook or primary source. Report an error.

In this unit: Working with data

  1. Spreadsheets for Economic AnalysisLearn to organize data in rows and columns, write formulas for growth and averages, and avoid common spreadsheet traps.10 min
  2. Charts That Tell the TruthLearn how axes, scales and choices of chart type can mislead, and how to draw honest charts of economic data.10 min
  3. Cleaning and Merging DataRaw data is messy. Learn to find and fix common problems, then join two tables safely on a shared key.12 min
  4. A First Look at Programming for Data AnalysisMeet variables, lists, loops, functions and tables in Python, using small economic examples you can follow line by line.11 min
  5. Summaries and Regressions in CodeUse a few lines of Python to describe a data set, fit a straight line, and read the results without being fooled.11 min
  6. Reproducible Work: Files, Notes and VersionsOrganize files, write down your steps and save versions so that you, or anyone else, can redo an analysis and get the same answer.11 min
  7. Time Series Basics: Trends, Growth Rates and Moving AveragesLearn to read data that comes in time order: find the trend, compute growth rates correctly, and smooth noise with a moving average.10 min
  8. Presenting Data Findings to Non-ExpertsTurn an analysis into a clear message for busy readers: lead with the answer, choose one chart, and be honest about doubt.10 min

In the news