Formulas
The formula language, its functions, and where it differs from what you know.
The formula language follows Google Sheets: its operators and their order, its coercions, its errors. A formula you would type there reads the same here. What is built is a small part of it: 33 functions, one value per formula, no dates.
Column B holds the formulas, column C shows how each was typed. Type over either.
What a cell holds
A cell keeps what was typed, as text. With = in front it is a formula. Anything
else is a value: a number (12, -1.5, .5, 1e3, 12%), TRUE or FALSE, or words. A
leading apostrophe keeps what follows as words: '0123, '=A1.
Operators
From the one that binds first to the one that binds last:
| Operator | What it does |
|---|---|
- in front, % behind | a sign and a percentage: -2^2 is 4, 50% is 0.5 |
^ | a power, worked out left to right: 2^3^2 is 64 |
* / | times, divided by |
+ - | plus, minus |
& | joins two values as text |
= <> < <= > >= | compares; text is compared without regard to case |
A blank cell counts as 0, as empty text or as FALSE, by what stands beside it. Text that reads
as a number counts as one in arithmetic: ="3"*2 is 6.
References
A cell is named by its column and row (B3), a range by two corners (A1:C3). A $ anchors what follows it: when a formula is copied, B3 moves along, $B$3 stays, and $B3 keeps its column. A
reference that leaves the sheet becomes #REF!. Whole columns and rows (A:A, 1:1), other sheets and named ranges are not built.
Functions
ABSANDAVERAGEAVERAGEIFCONCATCONCATENATECOUNTCOUNTACOUNTIFIFIFERRORINTLEFTLENLOWERMAXMEDIANMIDMINMODNOTORPOWERPRODUCTRIGHTROUNDROUNDDOWNROUNDUPSQRTSUMSUMIFTRIMUPPER
The names are English in every language, and arguments are separated by , or ; alike. A formula gives one value: a range where one value is expected is #VALUE!, and nothing fills the cells below.
Errors
| A cell shows | When |
|---|---|
#DIV/0! | a division by zero, an average of nothing |
#VALUE! | a value of the wrong kind: words where a number is needed, a range where one value is |
#REF! | a reference to a cell outside the sheet |
#NAME? | a function the engine does not know |
#NUM! | a number that cannot be: =SQRT(-1) |
#N/A | a function given too few or too many arguments |
#CYCLE! | cells that need each other in a circle; every cell of the circle shows it |
#ERROR! | a formula that cannot be read: =1+ |
An error travels: a cell that reads one shows it too. IFERROR catches it.
Where it differs
- Cells in a circle show
#CYCLE!, where Sheets shows#REF!. - Text is compared letter by letter without regard to case, not in a language's alphabet.
- The criteria of
SUMIF,COUNTIFandAVERAGEIFknow no wildcards (*,?). CONCATtakes any number of arguments, ranges too.- An argument cannot be left out between two separators:
=IF(A1,,1)cannot be read. - Of the errors, only
#REF!can be written into a formula. - Brackets and calls nest 64 deep at most.
Numbers and languages
A sheet keeps every number one way: a decimal point, no thousands separators. The grid shows and
takes them the reader's way, so in German 12,5 typed into a cell is the number 12.5
and reads 12,5. Inside a formula a number always has a decimal point, in every
language.
In code
The calculation is one function of the engine: createEvaluator(get) works a sheet
out from a function that answers a cell's input, each cell once, on first asking. The sheet and
the editor call it for you (sheet.evaluator(), editor.value(row, col)). shiftFormula moves a formula's references the
way copy and paste does, parseInput reads a typed value, and FUNCTIONS is the list above.