Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Excel Basics Cheat Sheet: Operators

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Excel Basics Cheat Sheet > Operators Use multiple logical conditions to determine the return value with

> Operators Use multiple logical conditions to determine the return value with IFS()
=IFS(cond1, return1, cond2, return2)

Arithmetic operators =IFS(A1 B1, "1st", A2 > B2, "2nd", B3, "3rd") Returns "3rd"

Learn Excel online at www.DataCamp.com


> A3 >

Similar IF(), but allowing multiple pairs of logical conditions and return values. If the first condition, cond1, is TRUE then the
to
=A2 + A3 Add two values with +. This example returns 3 + 6 =
function returns the first return value, return1. If the second condition, cond2 is TRUE, the function returns the second return value;
=A4 - B4 Subtract a value from another with -.This example returns 10 - 7 =
and so on.
=A6 * B1 Multiply two values with *. This example returns 21 * 2 = 4

> Definitions =C3 / B4 Divide two values with /. This example returns 28 /
=C5% Convert a value to a percentage with %. This
7 =
example returns 3.2 Provide a default value in case of errors with IFERROR()
=B1 ^ C1 Raise a value to power with ^. This example returns 2 ^ 6 = 64
=IFERROR(value, value_if_error)

This cheat sheet describes the behavior of the Microsoft 365 version of Excel, and slight differences exist between Excel versions.
=IFERROR(A5 / A5, 1) Division of two missing values gives an error; this returns 1

Numeric comparison operators


Definitions If the first input does not result in an error then it is returned. If it does result in an error, the second input is returned.
Test for equality with =
Test for inequality with <>

Spreadsheet: An application, like Microsoft Excel, where you can store data, perform calculations, and organize information.
=A1 = B1 Returns 1 = 2 which is FALSE

=A2 = B2 Returns 3 = 3 which is TRUE


=A1
=A2
< >
< >
B1 Returns 1
B2 Returns 3
< >
< >
2 which is TRUE

3 which is FALSE
Choose a return value based on a table of inputs with SWITCH()
Workbook: A file containing a collection of one or more worksheets.
Test greater than with >
Test greater than or equal to with >=
=SWITCH(value, choice1, return1, choice2, return2, ...)

Worksheet: A single page in a workbook. It is a grid of cells arranged in rows and columns. =A3 > = B3 Returns 5 > 5 which is TRUE
=A3 > = B3 Returns 6 > =5 which is TRUE
=SWITCH(MID(D3, 1, 5), "World", "planet", "Solar", "planetary system", "Milky", "galaxy", "Local",
=A2 > B2 Returns 3 > 3 which is FALSE =A2 > B2 Returns 3 > = 3 which is TRUE "galaxy group") Returns "galaxy"

Cell: A rectangular box in a worksheet that can store a data value, a formula, or other content.
Formula: A piece of code to perform a calculation. Formulas start with an equals sign (=), and contain functions, mathematical Test less than with <
Test less than or equal to with <=

Takes a value as its first argument, followed by pairs of choices and return values. If the value matches the first choice, the function
operators, values, and cell references. =A1 < B1 Returns 1 < 2 which is TRUE
=A1 < = B1 Returns 1 < = 2 which is TRUE

returns the first return value; if the value matches the second choice, the function returns the second return value; and so on. If no
Cell reference: The location of a cell. The column is described with letters and the row is described with numbers. For example, the =A2 < B2 Returns 3 < 3 which is FALSE =A2 < = B2 Returns 3 < = 3 which is TRUE
values match, the function returns an error.
cell in the 4th column, 7th row would be denoted D7.
Cell range: A group of adjacent cells in a worksheet. A cell range is typically referred to by its upper-left and lower-right cells, such

> Logical functions > Conditional computation


as A1:C3, referring to the cells in columns A, B, and C and rows 1 through 3. You can use cell ranges to perform calculations on
multiple cells at once or to apply formatting to a group of cells.

- A B C
Logical NOT with NOT()
Logical AND with AND()
Get the number of cells that meet a condition with COUNTIF()
1 Cell A1 Cell B1 Cell C1 =NOT(A1 = B1)
=AND(A1 > 10, B1 < 20)

Returns NOT(1 = 2) which is TRUE


Returns AND(1 > 10, 2 < 20) which is FALSE
=COUNTIF(A1:A6, ">5") Returns 3: the number of cells greater than 5, ignoring blanks

2 Cell A2 Cell B2 Cell C1


=NOT(A1 = B1)
=AND(A1 < 2, B1 < 20)
=COUNTIF(D1:D6, "Milky Way") Returns 1: the number of cells equal to “Milky Way”
3 Cell A3 Cell B3 Cell C3 Returns NOT(2 = 2) which is FALSE Returns AND(1 < 2, 2 < 20) which is TRUE

Logical OR with OR()


Logical XOR with XOR()
Calculate the total of cells meeting conditions with SUMIF() and SUMIFS()
=OR(A1 > 10, B1 < 20)
=XOR(A1 > 10, B1 < 20)

> Getting help Returns OR(1 > 10, 2 < 20) which is TRUE

=OR(A1 < 2, B1 < 20)

Returns XOR(1 > 10, 2 < 20) which is TRUE

=XOR(A1 > 10, B1 > 20)

=SUMIF(A1:A6, ">5") Returns 37: the sum of elements in A1 to A6 filtered with values greater than 5

=SUMIF(A1:A6, ">5", B1:B6) Returns 25: the sum of elements in B1 to B6 corresponding to values in A1 to A6 that are greater
Returns OR(1 < 2, 2 < 20) which is TRUE Returns XOR(1 > 2, 2 > 20) which is FALSE
than 5

You can get help by accessing the help menu =SUMIFS(B1:B6, A1:A6, ">5", D1:D6, "<>Local Group") Returns 18: the sum of B1:B6 where A1:A6 is greater than 5 and
D1:D6 is not equal to "Local Group"

Open Microsoft Excel


Click on the "Help" menu at the top of the screen
In the Help menu, you will see various options for getting help, including a search bar where you can enter keywords to search for > Data types Calculate the mean of cells meeting conditions with AVERAGEIF() & AVERAGEIFS()
specific topics =AVERAGEIF(A1:A6, ">5") Returns 12.33: the mean of elements in A1 to A6 filtered with values greater than 8

You can also click on the "Help" button to open the Help pane, where you can browse through various topics and find answers to =ISNUMBER(A1) Checks if a cell is a number. Returns TRU =AVERAGEIF(A1:A6, ">5", B1:B6) Returns 8.33: the mean of elements in B1 to B6 corresponding to values in A1 to A6 that are
common questions. =ISTEXT(D1) Checks if a cell is a text. Returns TRU greater than 5

=ISLOGICAL(A1) Checks if a cell is a boolean. Returns FALS =AVERAGEIFS(B1:B6, A1:A6, ">5", D1:D6, "<>Local Group") Returns 9: the mean of B1:B6 where A1:A6 is greater than 5
and D1:D6 is not equal to "Local Group"
How to add a comment to a cell =ISLOGICAL(A1=A1) Checks if a cell is a boolean. Returns TRU

=N(E1) Converts to number. Returns 44927: the serial date - the date as a number, counting Dec 31st 1899 as
Click on the cell where you want to add a comment =N(D1) Converts to number. Returns an error, since it’s not a numbe
Right-click or CTRL+click on the cell and select the "New Comment" option from the context menu. You can also click on the
Insert menu then "New Comment"
=VALUETOTEXT(A1) Convert to text. Returns "1
=TEXT(C6, "0.00E+0") Convert to formatted text. Returns "4.96E+2 > Text functions and operators
This will open a small text box next to the cell, where you can type your comment =DATEVALUE("1/1/2022") Convert text to serial. Returns 44927: the serial date
Once you have entered your comment, click the green arrow button to save it. Basics
=LEN(D5) Returns the length of a string in characters. This example returns 28.

> Cells and ranges > Counting data Combining and splitting strings
=COUNT(A5:E5) 3: the number of cells in the range containing numbers, dates and currencies
Returns ="Hello " & D1 & "!" Returns "Hello World!
Specifying cell locations with column letter, row number format =COUNTA(A5:E5) Returns 4: the number of cells in the range that aren't empt =REPT(D6, 3) Repeats text. This example returns "UniverseUniverseUniverse
=COUNTBLANK(A5:E5) Returns 1: the number of cells that are empty or contain the empty string ("") =TEXTSPLIT(D4, "o") Splits a string on a delimiter. This example returns "L", "cal Gr", "up" in 3 cells: "Local Group"
=B2 Here we refer to the cell in column B, row 2.
split on the letter "o
=TEXTSPLIT(D5, {"a","u"}) Splits a string on a delimiter. This example returns "L", "ni", "ke", "S", "percl",
Specifying absolute cell references with $ prefixes
> Math functions "ster" in 6 cells: "Laniakea Supercluster" split on the letter "a" or the letter "u".

The $ symbol before the column letter and/or row number tells Excel that the reference is absolute and should not change when the
formula is copied or moved to another cell. The following examples all specify column B, row 2.
=LOG(100, 10) Returns 2: the base 10 logarithm of 10
Mutating strings
=$B$2 Column and row references are both absolute
=EXP(2) Returns e^2 = 7.39
=MID(text, start, [length]) Extracts a substring starting at the position specified in the second argument and with the
=$B2 Column reference is absolute, row reference is relative
=MAX(A1:A6, C1:C3, 12) Returns 28: the largest value in all cell ranges or values inputte
length specified in the third argument. For example =MID(D6, 4, 5) Returns "verse
=B$2 Column reference is relative, row reference is absolute =MIN(A1:A6, C1:C3, 12) Returns 1: the smallest value in all cell ranges or values inputted
=UPPER(text) Converts the text to uppercase. For example =UPPER(D3) Returns "MILKY WAY
=MAXA(A1:A6, C1:C3, FALSE) Returns same as MAX(), except TRUE is valued at 1 and FALSE is valued at
=LOWER(text) Converts the text to lowercase. For example =LOWER(D3) Returns "milky way
Specifying ranges with the start:end format =MINA(A1:A6, C1:C3, FALSE) Returns same as MIN(), except TRUE is valued at 1 and FALSE is valued at
=PROPER(text) Converts the text to title case. For example =PROPER("milky way") Returns "Milky Way"
=SUM(A1:A6, C1:C3, 12) Returns 108: the total of all cell ranges or values inputte
The start:end format is a convenient way to specify a range of cells in a formula.
=AVERAGE(A1:A6, C1:C3, 12) Returns 12: the mean of all cell ranges or values inputte
Here is an example of start:end format when using the SUM() formula:
=MEDIAN(A1:A6, C1:C3, 12) Returns 10: the median of all cell ranges or values inputte
=SUM(B2:B5) =PERCENTILE.INC(C1:C6,
=ROUND(PI(), 2)
0.25) Returns 22.75: the 25th percentile of the cell rang
3.14: pi rounded to 2 decimal place
Returns
> Data manipulation
=CEILING(PI(), 0.1) Returns 3.2: pi rounded upwards to the nearest 0.
=FILTER(A1:B6, C1:C6>100) Gets a subset of the cell range in the first input that meets the condition in the second input
Example dataset
=FLOOR(PI(), 0.1) Returns 3.1: pi rounded downwards to the nearest 0.
> =VAR.S(B1:B6) Returns 19.37: sample variance of the cell rang
=STDEV.S(B1:B6) Returns 4.40: sample standard deviation of the cell range
=SORT(A1:E6, 4) Returns the dataset with rows in alphabetical order of the fourth column. Sorts the rows of the data
according to values in specified columns
=SORTBY(A1:E6, D1:D6) Returns the same as the SORT() example. Alternate, more flexible, syntax for sorting. Rather than
Throughout most of this cheat sheet, we’ll be using this dummy dataset of 5 columns and 6 rows. specifying the column number, you specify an array to sort by
=UNIQUE(A1:A6) Gets a list of unique values from the specified data
- A B C D E
> Flow control =SEQUENCE(5, 1, 3, 2) Returns 5 rows and 1 column containing the values 3, 5, 7, 9, 11. Generates a sequence of numbers,
1 1 2 6 World 1/1/2023 starting at the specified start value and with the specified step size.

2 3 3 21 Solar System 1/2/2023 Use a logical condition to determine the return value with IF()
3 6 5 28 Milky Way 1/3/2023
=IF(cond, return_if_true, return_if_false)

4 10 7 301 Local Group 1/4/2023 =IF(ISBLANK(A5), "A5 is blank", "A5 is not blank") Returns "A5 is blank"

Learn Excel Online at


www.DataCamp.com
5 21 11 325 Laniakea Supercluster 1/5/2023
Takes a logical condition, cond, as its first argument. If cond is TRUE, IF() returns the value specified in the second argument
6 21 13 496 Universe 1/6/2023 (return_if_true); if cond is TRUE, IF() returns the value specified in the third argument (return_if_false).

You might also like