Explanation
In this example, the goal to calculate the difference as a percentage between two values then check the result to see if its within a given target percentage. The values come from the Expected and Actual columns in the worksheet. The challenge is that the difference might be negative or positive, and we need to cater to both.
Difference as percentage
To calculate the difference as a percentage, we can use a general formula like this:
=(actual-expected)/expected
After converting this to cell references, we have:
=(C5-B5)/B5
As the formula is copied down, it returns a percentage difference in each row. Note that some values are negative.
Note: the results are decimal values like 0.05 and they must be formatted with the percentage number format to display as 5%, 7%, etc.
Compare to target
To compare the percentages to the target percentage, we use the IF function like this in cell E5:
=IF(ABS(D5)<=target,"Yes","No")
where target is the named range G5. This formula uses the ABS function to convert the percentages in column D to positive numbers. Then it uses the IF function to compare the result from ABS to the target (set to 5% in the example shown). If the logical test returns TRUE, the difference is within 5% and IF returns “Yes”. Otherwise, IF returns “No”. Notice both results are text values wrapped in double quotes ("").
As the formula is copied down, we get a new result in each row. If the value in G5 is changed to a new percentage, all results recalculate.
All-in-one-formula
In the example shown, column D is used to calculate the difference as a percentage, in order to make the example easier to understand. However, you can combine both formulas above into a single formula like this if needed:
=IF(ABS((C5-B5)/B5)<=target,"Yes","No")
The result is the same, but this version does not need to use column D as a helper column .
Explanation
In this example, the goal is to convert the percentages shown in column C to amounts, where the total of all amounts is given as $1945. In other words, if we know Rent is 36.0%, and the total of all expenses is $1945, we want to calculate that Rent is $700. With “x” as the number we want to find, we have:
=36.0%*1945=x
=0.36*1945
=700.20
Note: in the example, the percentage values in column C are unrounded decimal numbers like 0.359897172, which accounts for the 0.20 difference in the calculation above.
The total of all expenses is in cell D15, which is also the named range “total”. To perform this calculation in Excel, we simply multiply the percentage in column C by the total in cell D15. The formula in D6, copied down is:
=C6*total
Named ranges behave like absolute references by default, so the equivalent formula without a named range is:
=C6*$D$15
For each expense in the table, Excel returns a calculated amount.
Formatting percentages in Excel
In mathematics, a percentage is a number expressed as a fraction of 100. For example, 85% is read as “Eighty-five percent” and is equivalent to 85/100 or 0.85. Accordingly, the values in column C are decimal numbers. For example, C6 is approximately 0.36, C7 is approximately 0.18, etc. To display these numbers as a percentage with the percent sign (%), the Percentage number format has been applied to C6:C13.