You may have experience working with formulas that contain only one operator, like 7+9. More complex formulas can contain several mathematical operators, like 5+2*8. When there's more than one operation in a formula, the order of operations tells Excel which operation to calculate first. To write formulas that will give you the correct answer, you'll need to understand the order of operations.
Watch the video below to learn more about complex formulas.
The order of operations
Excel calculates formulas based on the following order of operations:
- Operations enclosed in parentheses
- Exponential calculations (3^2, for example)
- Multiplication and division, whichever comes first
- Addition and subtraction, whichever comes first
A mnemonic that can help you remember the order is PEMDAS, or Please Excuse My Dear Aunt Sally.
Example: 10+(6-3)/2^2*4-1
While this formula may look complicated, we can use the order of operations step by step to find the right answer.
- Parentheses (P): First, we'll start by calculating anything inside parentheses. In this case:
6-3=3.
Current formula:10+3/2^2*4-1 - Exponents (E): Next, we look for exponents. There is one:
2^2=4.
Current formula:10+3/4*4-1 - Multiplication & Division (MD): Next, we solve multiplication and division, working from left to right. Because division comes before multiplication here, it's calculated first:
3/4=0.75.
Current formula:10+0.75*4-1 - Multiplication (MD continued): Now, we solve the remaining multiplication:
0.75*4=3.
Current formula:10+3-1 - Addition & Subtraction (AS): Next, we calculate addition or subtraction, working left to right. Addition comes first:
10+3=13.
Current formula:13-1 - Subtraction (AS continued): Finally, we have one remaining subtraction:
13-1=12.
Answer: 12
And this is the exact same result you would get if you entered the formula into Excel.
Creating complex formulas
In the example below, we'll demonstrate how Excel uses the order of operations to solve a more complex formula. Here, we want to calculate the cost of sales tax for a catering invoice. To do this, we'll write our formula as =(D3+D4+D5)*0.075 in cell D6. This formula will add the prices of our items, then multiply that value by the 7.5% tax rate (which is written as 0.075) to calculate the answer.
Excel follows the order of operations and first adds the values inside the parentheses: (45.80+68.70+159.60) = 274.10. It then multiplies that value by the tax rate: 274.10*0.075. The result will show that the sales tax is $20.56.
It's especially important to follow the order of operations when creating a formula. Otherwise, Excel won't calculate the results accurately. In our example, if the parentheses are not included, the multiplication is calculated first and the result is incorrect. Parentheses are often the best way to define which calculations will be performed first in Excel.
To create a complex formula using the order of operations:
In the example below, we'll use cell references along with numerical values to create a complex formula that will calculate the subtotal for a catering invoice. The formula will calculate the cost of each menu item first, then add these values.
- Select the cell that will contain the formula. In our example, we'll select cell C5.
- Enter your formula. In our example, we'll type
=B3*C3+B4*C4. This formula will follow the order of operations, first performing the multiplication: 2.79*35 = 97.65 and 2.29*20 = 45.80. It then will add these values to calculate the total: 97.65+45.80. - Double-check your formula for accuracy, then press Enter on your keyboard. The formula will calculate and display the result. In our example, the result shows that the subtotal for the order is $143.45.
You can add parentheses to any equation to make it easier to read. While it won't change the result of the formula in this example, we could enclose the multiplication operations within parentheses to clarify that they will be calculated before the addition.
Challenge!
For this challenge, you will work with another invoice like the one in our example. In the invoice, you will find the amount of tax for the order, the order's total, and the order's total if you were given a 10% discount.
- Open our practice workbook.
- Click the Challenge worksheet tab in the bottom-left of the workbook.
- In cell D7, create a formula that calculates the tax for the invoice. Use a sales tax rate of 7.5%.
- In cell D8, create a formula that finds the total for the order. In other words, this formula should add cells D3:D7.
- In cell D9 create a formula that calculates the total after a 10% discount. If you need help understanding how to take a percentage off of a total, review our lesson on Discounts, Markdowns, and Sales.
- When you're finished, your spreadsheet should look like this:
Common Questions about Complex Formulas
What is PEMDAS in Excel?
PEMDAS stands for Parentheses, Exponents, Multiplication, Division, Addition, and Subtraction. It is the order of operations Excel follows when calculating formulas.
Why do I need to use parentheses in my formula?
Parentheses force Excel to calculate specific parts of the formula first. Without them, Excel might perform multiplication before addition, which could lead to incorrect results in scenarios like calculating tax totals.
What symbol is used for multiplication and division in Excel?
In Excel, use the asterisk (*) for multiplication and the forward slash (/) for division.
Why is my formula returning the wrong result?
This is often due to the order of operations. Check your formula to ensure that multiplication and division are not happening before addition or subtraction if you intended otherwise. Use parentheses to correct the order.
Can I put parentheses inside other parentheses?
Yes, this is called "nesting." Excel will calculate the innermost set of parentheses first and work its way outward.
No comments:
Post a Comment