ZetCode

Excel ABS Function

last modified April 4, 2025

The ABS function is a mathematical function in Excel that returns the absolute value of a number. Absolute value represents a number's magnitude without regard to its sign. This tutorial provides a comprehensive guide to using the ABS function with detailed examples. You'll learn basic syntax, practical applications, and advanced techniques to master this useful Excel function.

ABS Function Basics

The ABS function converts negative numbers to positive numbers while leaving positive numbers unchanged. It's particularly useful when you need to work with magnitudes or distances regardless of direction.

Component Description
Function Name ABS
Syntax =ABS(number)
Arguments number - The value you want the absolute value of
Return Value Non-negative number

This table breaks down the essential components of the ABS function. It shows the function name, basic syntax format, argument requirements, and return value characteristics.

Basic ABS Example

This example demonstrates the simplest use of the ABS function with a single number.

Basic ABS formula
=ABS(-10)

This formula converts the negative number -10 to its absolute value 10. The result will always be non-negative, regardless of the input's original sign.

ABS with Cell References

A more practical use of ABS involves referencing cells containing values. Here's an example with cell references.

A B
-15 =ABS(A1)

The table shows a simple spreadsheet with a negative value in cell A1 and an ABS formula in cell B1 that converts it to a positive value.

ABS with cell reference
=ABS(A1)

This formula returns the absolute value of whatever number is in cell A1. If A1 contains -15, the result will be 15. If A1 contains 15, the result remains 15.

ABS with Calculations

ABS can be used with mathematical operations to ensure results are non-negative. This example shows ABS applied to a calculation.

A B C
100 150 =ABS(A1-B1)

This table demonstrates using ABS to ensure the difference between two values is always expressed as a positive number, regardless of which value is larger.

ABS with calculation
=ABS(A1-B1)

This formula calculates the absolute difference between values in A1 and B1. The result will be 50 whether A1 is larger or smaller than B1. This is useful for distance calculations.

ABS with SUM Function

ABS can be combined with other functions like SUM to ensure totals are non-negative. This example demonstrates this combination.

A B
-5
10
-3
=ABS(SUM(A1:A3))

The table shows how ABS can wrap around a SUM function to ensure the total is non-negative, regardless of the individual values' signs.

ABS with SUM function
=ABS(SUM(A1:A3))

This formula first sums the range A1:A3 (-5+10-3=2) then applies ABS to the result. While not necessary in this case (since the sum is already positive), it guarantees a non-negative result for any combination of values.

ABS with IF Function

ABS can be combined with IF to create conditional absolute value calculations. This example shows this powerful combination.

A B C
-25 Yes =IF(B1="Yes", ABS(A1), A1)

The table demonstrates how to conditionally apply the ABS function based on another cell's value. In this case, ABS is only applied if B1 contains "Yes".

ABS with IF function
=IF(B1="Yes", ABS(A1), A1)

This formula checks if B1 equals "Yes". If true, it returns the absolute value of A1 (25). If false, it returns A1 unchanged (-25). This allows flexible application of ABS based on conditions.

ABS with Text Values

ABS returns a #VALUE! error when applied to text values. This example shows this behavior and how to handle it.

A B
Text =ABS(A1)

The table illustrates how ABS reacts when given a text value instead of a number. The function cannot process text and returns an error.

ABS with text value
=ABS(A1)

This formula attempts to get the absolute value of a text string in A1. Since ABS only works with numbers, it returns #VALUE! error. You would need to ensure the cell contains a numeric value first.

ABS with Zero

ABS returns zero when applied to zero, maintaining mathematical consistency. This example demonstrates this behavior.

A B
0 =ABS(A1)

The table shows that applying ABS to zero simply returns zero, which is mathematically correct since zero has no sign to remove.

ABS with zero
=ABS(A1)

This formula returns the absolute value of zero, which is zero. This demonstrates that ABS doesn't change zero values, as they're already non-negative.

ABS in Array Formulas

ABS can be used in array formulas to process multiple values at once. This example shows ABS applied to an array of values.

ABS in array formula
=SUM(ABS({-1,2,-3,4}))

This array formula first converts each number in the array {-1,2,-3,4} to its absolute value {1,2,3,4}, then sums them (result: 10). This technique is powerful for batch processing values.

The ABS function is essential for working with magnitudes, differences, and distances in Excel. From simple sign removal to complex conditional calculations, ABS provides reliable mathematical operations. Remember that ABS only works with numeric values and will return errors for text inputs. Mastering ABS will enhance your ability to work with signed numbers in spreadsheets.

Author

My name is Jan Bodnar, and I am a passionate programmer with extensive programming experience. I have been writing programming articles since 2007. To date, I have authored over 1,400 articles and 8 e-books. I possess more than ten years of experience in teaching programming.

List all Excel Formulas.