Excel Formulas
Excel Formulas
Microsoft Excel is a popular tool for managing data and performing data analysis. It is used for
generating analytical reports, business insights, and storing operational records. To perform simple
calculations or analyses of data, we need Excel formulas.
An Excel formula is an expression used to perform calculations or manipulate data within an Excel
spreadsheet. A formula always begins with an equal sign (=), which tells Excel to interpret the entry
as a calculation rather than plain text. Formulas typically involve mathematical operations, cell
references, functions, and operators.
Some of the most important formulas worth knowing in Excel are basic
functions: SUM(), MIN(), MAX(), AVERAGE(), COUNT(), POWER(), CEILING(), FLOOR(), CONCAT(
), TRIM(), REPLACE(), SUBSTITUTE(), LEFT(), RIGHT(), MID(), UPPER(), LOWER(), PROPER(
), NOW(), TODAY(), DATEDIF(), VLOOKUP(), HLOOKUP(), and IF(). See below for guidance on each
of these.
1. Efficiency: They automate repetitive tasks, saving time and reducing manual errors.
2. Data analysis: Excel's range of formulas enables sophisticated data analysis, crucial for informed decision-
making.
3. Accuracy: Formulas ensure consistent and accurate results, essential in fields like finance and accounting.
4. Data manipulation: They allow for efficient sorting, filtering, and manipulation of large datasets.
5. Accessibility: Excel provides a user-friendly platform, making complex data analysis accessible to non-
technical users.
6. Versatility: Widely used across various industries, proficiency in Excel formulas enhances employability and
career advancement.
7. Customization: Excel offers customizable formula options to meet specific data handling needs.
In essence, Excel formulas are a foundational tool for effective data management, analysis, and decision-
making.
Adding the Excel formula is relatively easy. It will come to you naturally if you are familiar with any business
intelligence software.
The most effective and fast way to use formulas is by adding them manually. In the example below, we are
calculating the BMI (Body Mass Index) of the athletes shown in the table.
1. Choose the cell for the resulting output. You can use the mouse to select the cell or use the arrow key to
navigate.
2. Type = in the cell. The equal sign will appear in the cell and formula bar.
3. Type the address of the cell that we want to use for our calculation. In our case, it is E2 (weight/KG).
4. Add divide sign /
5. To convert height from centimeters to a meter, we will divide the D2 by 100.
6. Take the squared ^2 of the height and press Enter.
Note: To get the address of any cell, you need to look at the column name (A, B, C, … ) and combine it with a
row number (1, 2, 3, …). For example, A2, B5, and C12
We can also add the Excel formula by using assisted GUI. It is simple.
In the example below, we will be using GUI to add an IF() functon to convert ‘M’ to ‘Male’ and ‘F’ to
Female.
This works similarly to an if-else statement. If the logical_test statement is TRUE, the formula will return
“Male” otherwise “Female.”
We have learned to add the formula to a single row. Now, we will learn to apply the same formula to the entire
column.
Dragging down the fill handle: when you select the cell, you will see the small green box at the bottom right. It
is called a fill handle. Click and hold the fill handle and drag it down to the last row. It is commonly used to
apply formulas to selected rows.
Double click the fill handle: select the cell with the formula and double click the fill handle. Within seconds it
will apply the formula to the entire column.
Shortcut: select the cell with the formula and the empty cells below it. Press CTRL + D to apply the formula.
Make sure you are not selecting anything above the formula cell.
Copy-pasting: copy the cell with the formula (CTRL + C), select the empty rows in a column, and paste it
(CTRL + V). Make sure you are not using a fill handle to select the rows.
The visual representation below shows all the ways we can apply the formula to multiple cells.
Let's now review important formulas in Excel. We will start by looking at common and important functions,
which, as we said, are built-in operations that can be used within formulas to perform specific tasks.
For this section, we will use a small subset of the Olympics dataset from DataCamp. To keep things
simple, we will mainly use the name, sex, age, height, and weight columns of four athletes' records.
For each of these, you will be writing the function name and arguments. That’s it, nothing complex.
1. SUM()
The SUM() function performs addition on selected cells. It works on cells containing numerical values and
requires two or more cells.
In our case, we will be applying the SUM() function to a range of cells from C2 to C5 and storing the result on
C6. It will add 24, 23, 21, and 31. You can also apply this function to multiple columns.
=SUM(C2:C5)
PO W E RE D B Y
The MIN() function requires a range of cells, and it returns the minimum value. For example, we want to
display the minimum weight among all athletes on the E6 cell. The MIN() function will search for the
minimum value and show 60.
=MIN(E2:E5)
PO W E RE D B Y
The MAX() function is the opposite of MIN(). It will return the maximum value from the selected range of
cells. The function will look for the maximum value and return 82.
=MAX(E2:E5)
PO W E RE D B Y
3. AVERAGE()
The AVERAGE() function calculates the average of selected cells. You can provide a range of cells (C2:C5) or
select individual cells (C2, C3, C5).
To calculate the average of athletes, we will select the age column, apply the average function, and return the
result to the C7 cell. It will sum up the total values in the selected cells and divide them by 4.
=AVERAGE(C2:C5)
PO W E RE D B Y
4. COUNT()
The COUNT() function counts the total number of selected cells. It will not count the blank cells and different
data formats other than numeric.
We will count the total number of athlete weights, and it will return 4, as we don’t have missing values or
strings.
=COUNT(E2:E5)
PO W E RE D B Y
To count all types of cells (date-time, string, numerical), you need to use the COUNTA() function.
The COUNTA() function does not count missing values. For blank cells, use COUNTBLANK().
5. POWER()
In the beginning, we learned to add power using ^, which is not an efficient way of applying power to a cell.
Instead, we recommended using the POWER() function to square, cube, or apply any raise to power to your
cell.
In our case, we have divided D2 by 100 to get height in meters and squared it by using the POWER() function
with the second argument as 2.
=POWER(D2/100,2)
PO W E RE D B Y
6. CEILING() and FLOOR()
The CEILING() function rounds a number up to the nearest given multiple. In our case, we will round 3.24 up
to a multiple of 1 and get 4. If the multiple is 5, it will round up the number 3.24 to 5.
=CEILING(F2,1)
PO W E RE D B Y
FLOOR() rounds a number down to the nearest given multiple. As we can see in the image below, instead of
converting 3.24 to 4, it has rounded the number to 3.
=FLOOR(F2,1)
PO W E RE D B Y
7. CONCAT()
The CONCAT() Excel function joins or merges multiple strings or cells with strings into one. For example, if
we want to join the age and sex of the athletes, we will use CONCAT(). The function will automatically convert
a numeric value from age to string and combine it.
“24”+“M” = “24M”
=CONCAT(C2,B2)
PO W E RE D B Y
8. TRIM()
TRIM() is used to remove extra spaces from the start, middle, and end. It is commonly used to identify
duplicate values in cells, and for some reason, extra space makes it unique.
For example:
1. There are extra two spaces at A3 “A Lamusi”, and it has been successfully removed by TRIM().
2. At A4 “ Christie Jacoba Aaftink”, there is extra space at the start, and without writing any complex
function, TRIM() has removed it.
=TRIM(A4)
PO W E RE D B Y
REPLACE() is used for replacing part of the string with a new string.
For example, we will change A Dijiang with B Dijiang by providing the positing of character, which is 1, the
number of characters that we want to replace, which is also 1, and the new character “B”.
=REPLACE(A2,1,1,"B")
PO W E RE D B Y
The SUBSTITUTE() function is similar to REPLACE(). Instead of providing the location of a character or the
number of characters, we will only provide old text and new text.
In our case, we are replacing "Jacoba" with "Rahim" to display the result on A4 cell “Christine Rahim Aaftink.”
This function is quite useful as it does not change the text without “Jacoba” as shown below in cell A5, “Per
Knut Aaland.” Whereas, REPLACE() will replace the text every time.
=SUBSTITUTE(A4,"Jacoba","Rahim")
PO W E RE D B Y
The LEFT() function returns the number of characters from the start of the string or text.
For example, to display the first name from the text “Christine Jacoba Aaftink”, you will use LEFT() with 9
numbers of characters. As a result, it will show the first nine characters; “Christine.”
=LEFT(A2,9)
PO W E RE D B Y
The MID() function requires a starting position and length to extract the characters from the middle.
For example, if you want to display a middle name, you will start with “J” which is at the 11th position, and 6
for the length of the middle name “Jacoba”.
=MID(A2,11,6)
PO W E RE D B Y
The RIGHT() function will return the number of characters from the end. You just need to provide a number of
characters.
For example, to display the last name “Aaftink,” we will use RIGHT() with seven characters.
=RIGHT(A2,7)
PO W E RE D B Y
The UPPER(), LOWER(), and PROPER() functions are basic string operations. You can find similar in
Tableau or in Python. These functinos only require a text, the location of the cell containing string, or the range
of cells with string.
=UPPER(A1:F1)
PO W E RE D B Y
LOWER() will convert the selected text to lowercase.
=LOWER(A1:F1)
PO W E RE D B Y
PROPER() will convert the string to the proper case. For example, the first letter in each word will be
capitalized, and the rest of them will be lowercase.
=PROPER(A1:F1)
PO W E RE D B Y
NOW() returns the current time and date, and TODAY() returns only the current date. These are quite simple,
and we will use them to extract a day, month, year, hours, and minutes from any date time data cell.
PO W E RE D B Y
To extract the seconds from the time, you will use the SECOND() function.
=SECOND(NOW())
PO W E RE D B Y
=TODAY()
PO W E RE D B Y
Furthermore, you can extract month, year, weekday, day names, hours, and minutes from the date time data
field.
=DAY(TODAY())
PO W E RE D B Y
13. DATEDIF()
It is the most used function for time series data sets. The DATEDIF() calculates the difference between two
dates and returns the number of days, months, weeks, or years based on your preference.
In the example below, we want to return the date difference in days by providing “d” for unit arguments. Make
sure that the first argument is the start date and the second argument in the function is the end date.
=DATEDIF(A2,B2,"d")
PO W E RE D B Y
14. IF()
The IF() Excel function is straightforward. It is similar to an if-else statement in a programming language. We
will provide the logic of the function. If the logic is correct, it will return a certain value; if the logic is false, it
will return a different value.
For example, if the BMI of athletics is less than 23.9, the function will return the string “Fit”, else “Unfit”. It is
quite useful to convert numerical values into categories.
=IF(G2<24.9,"Fit,"Unfit")
PO W E RE D B Y