Formulas cheat sheet
Using formulas in the spreadsheet.
Navigation
Operators
1
x%
Percent (divides by 100)
2
+x
positive
-x
negative
3
a:b
cell range
4
a..b
numeric range
5
a^b or a**b
Exponentiation
6
a*b
Multiplication
a/b
Division
7
a+b
Addition
a-b
Subtraction
8
a&b
String concatenation
9
a=b
or a==b
Equal comparison
a<>b
or a!=b
Not equal comparison
a<b
Less than comparison
a>b
Greater than comparison
a<=b
Less than or equal to comparison
a>=b
Greater than or equal to comparison
Math Functions
SUM([range])
Adds all values in range and returns 0 if given no values.
SUMIF(eval_range, criteria, [numbers_range])
Evaluates each value based on some criteria, and then adds the ones that meet those criteria. If range_to_sum
is given, then values in range_to_sum
are added instead wherever the corresponding value in range_to_evaluate
meets the criteria.
PRODUCT([range])
Multiply all values in the range. Returns 1 if given no values.
ABS(number)
Return the absolute value of a number.
SQRT(number)
Returns the square root of a number.
MOD(dividend, divisor)
Returns the result of modulus - this is the remainder after performing division.
PI()
Returns π, the constant.
TAU()
Returns τ, the circle constant equal to 2π.
CEILING(number, factor)
Rounds up a number by the defined factor. Number and Factor both required.
CEILING.MATH(number, factor)
Rounds up a number by the defined factor. Number and Factor both required.
FLOOR(number, factor)
Rounds down a number by the defined factor. Number and factor both required.
FLOOR.MATH(number, factor)
Rounds down a number by the defined factor. Number and factor both required.
INT(number)
Rounds number down to the nearest integer that is less than or equal.
Trig Functions
DEGREES(radians)
Converts radians to degrees.
RADIANS(degrees)
Converts degrees to radians.
SIN(radians)
ASIN(number)
COS(radians)
ACOS(number)
ATAN2(x, y)
TAN(radians)
ATAN(number)
CSC(radians)
ACSC(number)
SEC(radians)
ASEC(number)
COT(radians)
ACOT(number)
SINH(radians)
ASINH(number)
COSH(radians)
ACOSH(number)
TANH(radians)
ATANH(number)
CSCH(radians)
ACSCH(number)
SECH(radians)
ASECH(number)
COTH(radians)
ACOTH(number)
Statistics Functions
AVERAGE([numbers...])
Returns the arithmetic mean of all values.
AVERAGEIF(eval_range, criteria, [numbers_range])
Evaluates each value based on some criteria, and then computes the arithmetic mean of the ones that meet those criteria. If range_to_average
is given, then values in range_to_average
are averaged instead wherever the corresponding value in range_to_evaluate
meets the criteria.
COUNT([numbers...])
Returns the number of numeric values.
COUNTIF(range, criteria)
Evaluates each value based on some criteria, and then counts how many values meet those criteria.
COUNTBLANK([range...])
Counts how many values in the range are empty. Cells with formula or code output of an empty string are also counted.
MIN([numbers...])
Returns the smallest value. Returns +∞ if given no values.
MAX([numbers...])
Returns the largest value. Returns -∞ if given no values.
Logic Functions
These functions treat FALSE
and 0
as "falsey" and all other values are "truthy."
When used as a number, TRUE
is equivalent to 1
and FALSE
is equivalent to 0
.
TRUE()
Returns TRUE
.
FALSE()
Returns FALSE
.
NOT(a)
Returns TRUE
if a
is falsey and FALSE
if a
is truthy.
AND(a, b, ...)
Returns TRUE
if all values are truthy and FALSE
if any values is falsey. \ Returns TRUE
if given no values.
OR(a, b, ...)
Returns TRUE
if any value is truthy and FALSE
if any value is falsey. Returns FALSE
if given no values.
XOR(a, b, ...)
Returns TRUE
if an odd number of values are truthy and FALSE
if an even number of values are truthy. Returns FALSE
if given no values.
IF(cond, t, f)
Returns t
if cond
is truthy and f
if cond
if falsey.
IFERROR(value, fallback)
Returns first value if not error, second value if error.
String Functions
CONCAT(a, b, ...)
LEN(s)
Returns the number of characters in a string.
LENB(s)
Returns the length of string in bytes.
Lookup Functions
INDIRECT(cellref_string)
Returns the value of the cell at a given location.
INDEX(range, [row], [column], [range_num])
Returns the content of a cell or range of cells based on row and column offset within a range.
MATCH(search_key, search_range, search_type)
Returns the relative position of an item in a range that matches a specified value.
VLOOKUP
VLOOKUP(search_key, search_range, output_col, [is_sorted])
Examples:
VLOOKUP(17, A1:C10, 3)
VLOOKUP(17, A1:C10, 2, FALSE)
Searches for a value in the first vertical column of a range and return the corresponding cell in another vertical column, or an error if no match is found.
If is_sorted
is TRUE
, this function uses a binary search algorithm, so the first column of search_range
must be sorted, with smaller values at the top and larger values at the bottom; otherwise the result of this function will be meaningless. If is_sorted
is omitted, it is assumed to be false
.
If any of search_key
, output_col
, or is_sorted
is an array, then they must be compatible sizes and a lookup will be performed for each corresponding set of elements.
HLOOKUP
HLOOKUP(search_key, search_range, output_row, [is_sorted])
Examples:
HLOOKUP(17, A1:Z3, 3)
HLOOKUP(17, A1:Z3, 2, FALSE)
Searches for a value in the first horizontal row of a range and return the corresponding cell in another horizontal row, or an error if no match is found.
If is_sorted
is TRUE
, this function uses a binary search algorithm, so the first row of search_range
must be sorted, with smaller values at the left and larger values at the right; otherwise the result of this function will be meaningless. If is_sorted
is omitted, it is assumed to be false
.
If any of search_key
, output_col
, or is_sorted
is an array, then they must be compatible sizes and a lookup will be performed for each corresponding set of elements.
XLOOKUP
XLOOKUP(search_key, search_range, output_range, [fallback], [match_mode], [search_mode])
Examples:
XLOOKUP("zebra", A1:Z1, A4:Z6)
XLOOKUP({"zebra"; "aardvark"}, A1:Z1, A4:Z6)
XLOOKUP(50, C4:C834, B4:C834, {-1, 0, "not found"}, -1, 2)
Searches for a value in a linear range and returns a row or column from another range.
search_range
must be either a single row or a single column.
Match modes
There are four match modes:
0 = exact match (default)
1 = next smaller
1 = next larger
2 = wildcard
Search modes
There are four search modes:
1 = linear search (default)
1 = reverse linear search
2 = binary search
2 = reverse binary search
Linear search finds the first matching value, while reverse linear search finds the last matching value.
Binary search may be faster than linear search, but binary search requires that values are sorted, with smaller values at the top or left and larger values at the bottom or right. Reverse binary search requires that values are sorted in the opposite direction. If search_range
is not sorted, then the result of this function will be meaningless.
Binary search is not compatible with the wildcard match mode.
Result
If search_range
is a row, then it must have the same width as output_range
so that each value in search_range
corresponds to a column in output_range
. In this case, the search axis is vertical.
If search_range
is a column, then it must have the same height as output_range
so that each value in search_range
corresponds to a row in output_range
. In this case, the search axis is horizontal.
If a match is not found, then fallback
is returned instead. If there is no match and fallback
is omitted, then returns an error.
If any of search_key
, fallback
, match_mode
, or search_mode
is an array, then they must be compatible sizes and a lookup will be performed for each corresponding set of elements. These arrays must also have compatible size with the non-search axis of output_range
.
Arrays
An array can be written using {}
, with ,
between values within a row and ;
between rows. For example, {1, 2, 3; 4, 5, 6}
is an array with two rows and three columns:
1
2
3
4
5
6
Arrays cannot be empty and every row must be the same length.
Numeric ranges (such as 1..10
) and cell ranges (such as A1:A10
) also produce arrays. All operators and most functions can operate on arrays, following these rules:
Operators always operate element-wise. For example,
{1, 2, 3} + {10, 20, 30}
produces{11, 22, 33}
.Functions that take a fixed number of values operate element-wise. For example,
NOT({TRUE, TRUE, FALSE})
produces{FALSE, FALSE, TRUE}
.Functions that can take any number of values expand the array into individual values. For example,
SUM({1, 2, 3})
is the same asSUM(1, 2, 3)
.
When arrays are used element-wise, they must be the same size. For example, {1, 2} + {10, 20, 30}
produces an error.
When an array is used element-wise with a single value, the value is expanded into an array of the same size. For example, {1, 2, 3} + 10
produces {11, 12, 13}
.
Criteria
Some functions, such as SUMIF()
, take a criteria parameter that other values are compared to. A criteria value can be a literal value, such as 1
, FALSE
, "blue"
, etc. A literal value checks for equality (case-insensitive). However, starting a string with a comparison operator enables more complex criteria:
Symbol
Description
"=blue"
or "==blue"
Equal comparison
"<>blue"
or "!=blue"
Not-equal comparison
"<blue"
Less-than comparison
">blue"
Greater-than comparison
"<=blue"
Less-than-or-equal comparison
">=blue"
Greater-than-or-equal comparison
For example, COUNTIF(A1:A10, ">=3")
counts all values greater than or equal to three, and COUNTIF(A1:A10, "<>blue")
counts all values not equal to the text "blue"
(excluding quotes).
Numbers and booleans are compared by value (with TRUE
=1 and FALSE
=0), while strings are compared case-insensitive lexicographically. For example, "aardvark"
is less than "Camel"
which is less than "zebra"
. "blue"
and "BLUE"
are considered equal.
Wildcards
Wildcard patterns can be used …
… When using a criteria parameter with an equality-based comparison (
=
,==
,<>
,!=
, or no operator)… When using the
XLOOKUP
function with amatch_mode
of2
In wildcards, the special symbols ?
and *
can be used to match certain text patterns: ?
matches any single character and *
matches any sequence of zero or more characters. For example, DEFEN?E
matches the strings "defence"
and "defense"
, but not "defenestrate"
. *ATE
matches the strings "ate"
, "inflate"
, and "late"
, but not "wait"
. Multiple ?
and *
are also allowed.
To match a literal ?
or *
, prefix it with a tilde ~
: for example, COUNTIF(A1:A10, "HELLO~?")
matches only the string "Hello?"
(and uppercase/lowercase variants).
To match a literal tilde ~
in a string with ?
or *
, replace it with a double tilde ~~
. For example, COUNTIF(A1:A10, "HELLO ~~?")
matches the strings "hello ~Q"
, "hello ~R"
, etc. If the string does not contain any ?
or *
, then tildes do not need to be escaped.
Unimplemented list
This is the list of Formulas that we are currently building and will be adding in the near future. If there is a Formula that is not implemented and not on this list please contact us.
Last updated