ShareYourGroupShareYourGroupGoogle Sheets

Guides

How formulas work in Google Sheets

A formula is an instruction that works something out and shows the answer in a cell. Change a number it depends on and the answer changes by itself. This guide covers the basics, with the points where Google Sheets has its own way of doing things.

Start with an equals sign

Click a cell, type =, then the calculation, and press Enter.

Sample sheet: Marks of eight students in three subjects. One Science mark is missing (cell D6 is empty).
ABCDE
1NameClassMathsScienceEnglish
2Asha8A788591
3Ravi8B455260
4Meena8A928879
5Kabir8B334138
6Tara8A6772
7Joy8B889084
8Neha8A546158
9Imran8B787369

The operators are +, -, *, /, ^ for powers, & to join text, and the comparisons =, <>, >, <, >=, <=.

As you type a function name, Sheets shows a list of suggestions and then a small help box with the arguments. Press Tab to accept a suggestion.

Ranges

Other tabs and other files

A cell on another tab is written with the tab's name and an exclamation mark: =Prices!B2. If the name has spaces, put it in single quotation marks: ='Price List'!B2.

A cell in another spreadsheet file cannot be referred to directly. Use IMPORTRANGE.

Copying a formula: relative and fixed references

Drag the small square at the corner of a cell to copy its formula down. The references move with it: =C2*2 becomes =C3*2 on the next row.

To stop a reference moving, lock it with dollar signs: $F$1 always points to F1. Press F4 while editing to add them. $F1 locks only the column and F$1 only the row.

A cell or range can also be given a name, under Data, Named ranges. =B2*TaxRate then reads clearly and never moves.

One formula for a whole column

Sheets offers an alternative to copying down. Wrap the formula in ARRAYFORMULA and give it ranges:

=ARRAYFORMULA(IF(A2:A="", "", C2:C+D2:D+E2:E))

One formula in row 2 fills the entire column and covers rows added later. Functions such as FILTER, SORT, UNIQUE and QUERY return whole blocks of results in the same way. The cells they fill must be empty, or the formula shows #REF!.

Commas or semicolons?

The character between arguments depends on the spreadsheet's locale, under File, Settings. With the locale set to India, the United Kingdom or the United States, it is a comma. In locales where the comma is the decimal mark, it is a semicolon: =IF(A1>5;"Yes";"No"). If a formula copied from this site is rejected, check the locale. The locale also decides how typed dates are read and how currency is shown.

Seeing and checking formulas

When the cell shows an error

A result beginning with a hash sign means the formula could not be worked out. The guide to errors in Google Sheets explains each one.

Good habits

  1. Keep figures that may change, such as a rate or a pass mark, in their own labelled cells.
  2. One kind of data per column. A column that mixes text and numbers trips up QUERY, sorting and totals.
  3. Do not type in cells that a spilling formula needs.
  4. Check a new formula against one row worked out by hand.

The results on this page were worked out by us from the sample sheet; they were not produced by a script running Google Sheets. If Sheets shows you something different, please tell us.

This is an independent help site. It is not connected with or approved by Google. Google Sheets is a trademark of Google LLC, named here only to say which program a formula is for. The people and figures in the sample sheets are made up.