The tutorial explains the concept of the absolute value of a number and shows some practical applications of the ABS function to calculate absolute values in Excel: sum, average, find max/min absolute value in a dataset.
One of the fundamental things we know about numbers is that they can be positive and negative. But sometimes you may need to use only positive numbers, and that's where the absolute value comes in handy.
In simple terms, the absolute value of a number is the distance of that number from zero on a number line, regardless of the direction.
For example, the absolute value of the number 3 and -3 is the same (3) because they are equally far from zero:
From the above visual, you can figure out that:
In math, the absolute value of x is denoted as |x| like in these examples:
|-10| = 10 |10| = 10
In Excel, there is no absolute value symbol, but there is a special function for getting an absolute value - ABS function.
Note. Excel absolute value should not be confused with absolute cell reference. The latter is a special form of a cell address that locks a reference to a given cell.
The ABS function in Excel has just one purpose - to get the absolute value of a number.
Where number is the number you want to get the absolute value of. It can be represented by a value, cell reference or another formula.
For example, to find the absolute value of a number in cell A2, you use this formula:
The following screenshot shows our absolute formula in Excel:
You now know the concept of absolute value and how to calculate it in Excel. But can you think of real-life applications of an absolute formula? The following examples will hopefully help you gain a better understanding of what you are really finding.
In situations when you need to change negative number to positive numbers, the Excel ABS function is an easy solution.
Supposing, you calculate the difference between two numbers by subtracting one number from the other. The problem is that some of the results are negative numbers while you want the difference to always be a positive number:
Wrap the formula in the ABS function:
And have the negative numbers converted to positive, leaving the positive numbers unaffected:
Another common application of the ABS function in Excel is to find whether a given value (number or percentage) is within expected tolerance or not.
With the actual value in A2, expected value in B2, and the tolerance in C2, you build the formula in this way:
=IF(ABS(A2-B2)<=C2, "Yes", "No")
To get an absolute sum of all numbers in a range, use one of the following formulas:
In the first case, you use an array formula to force the SUM function to add up all the numbers in the specified range. SUMPRODUCT is an array type function by nature and can handle a range without extra manipulations.
With the numbers to be summed in cells A2:B5, either of the following formulas will work a treat:
Array formula, completed by pressing Ctrl + Shift + Enter:
Regular formula, completed with a usual Enter keystroke:
As shown in the screenshot below, both formulas sum absolute values of positive and negative numbers, ignoring the sign:
The easiest way to get the minimum and maximum absolute value in Excel is to use the following array formulas.
Maximum absolute value:
Minimum absolute value:
With our sample dataset in A2:B5, the formulas take the following shape:
To get the max absolute value:
To find the min absolute value:
Please be sure to properly complete the array formulas by pressing Ctrl+Shift+Enter.
If you don't like using array formulas in your worksheets, you can trick the ABS function into processing a range by nesting it into the array argument of the INDEX function like shown below.
To get the maximum absolute value:
To get the minimum absolute value:
This works because an INDEX formula with the row_num and column_num arguments set to 0 or omitted tells Excel to return a whole array rather than an individua value.
The formulas we used to calculate the min/max absolute value can average absolute values too. You will just have to replace MAX/MIN with the AVERAGE function:
For our sample data set, the formulas would go as follows:
Array formula to average absolute values (entered by pressing Ctrl + Shift + Enter):
Regular formula to average absolute values:
Apart from the typical uses of an absolute value demonstrated above, the Excel ABS function can be used in combination with other functions to handle the tasks for which there is no built-in solution. Below you can find a few examples of such formulas.
Get a date closest to today - an absolute value is used to get a date nearest to today.
Calculate rank by absolute value - rank numbers by their absolute values ignoring the sign.
Extract a decimal part of a number - get a fractional part of a number as an absolute value.
Get a square root of a negative number - take a square root of a negative number as if it were a positive number.
That's how to do absolute value in Excel by using the ABS function. The formulas discussed in this tutorial are very straightforward and you will hardly have any difficulties adjusting them for your worksheets. To have a closer look, you're welcome to download our sample Excel Absolute Value workbook.
I thank you for reading and hope to see you on our blog next week!
Table of contents