How to Get the Absolute Value in Excel – 8 Methods

This is an overview:

Overview image of how to get absolute value in Excel

 


The sample dataset showcases the name of the Brand, and the present day, and the previous day sales.

Dataset to Get Absolute Value in Excel

To find the variance of sales the following formula was used in E5. The Fill Handle icon was dragged down to the rest of the cells.

=D5-C5

Calculate variance for absolute value

The output includes both positive and negative values in the Variance column.


Method 1 – Using the Excel ABS Function to Get the Absolute Value

  • Go to F5 and enter the following formula.
=ABS(E5)
  • Drag down the Fill Handle to see the result in the rest of the cells.

ABS function to get absolute value

The ABS function returns the absolute value of the given reference.

Read More: Opposite of ABS Function in Excel


Method 2 – Apply a Condition Using the IF Function to the Get Absolute Value

  • Go to F5 and enter the following formula.
  • Drag down the Fill Handle to see the result in the rest of the cells.
=IF(E5<0,-E5,E5)

Excel IF function to get absolute value

The absolute value for variances is displayed in column F.


Method 3 – Combining the SQRT and the POWER Functions to Find the Absolute Value

  • Go to F5 and enter the following formula.
  • Drag down the Fill Handle to see the result in the rest of the cells.
=SQRT(POWER(E5,2))

Combination of SQRT and POWER function to get absolute value

You can also use the caret (^)” operator instead of the POWER function:

=SQRT(E5^2))

Method 4 – Using the Excel MAX Function to Get the Absolute Value by Comparing it to the Opposite Value

  • Go to F5 and enter the following formula.
  • Drag down the Fill Handle to see the result in the rest of the cells.
=MAX(-1*E5,E5)

MAX function to get absolute value


Method 5 – Using the SIGN Function to Multiply a Given Number by its Sign and get the Absolute Value

  • Go to F5 and enter the following formula.
=SIGN(E5)*E5 
  • Drag down the Fill Handle to see the result in the rest of the cells.

SIGN function to get absolute value in Excel

The formula converts the negative number into a positive, and the positive number does not change.


Method 6 – How to Get the Absolute Value Using a Pivot Table in Excel 

Steps:

  • Select B4:E9 >> Insert >> PivotTable >> From Table/Range.

Create Pivot Table in Excel

  • In the PivotTable from table or range window, select Existing Worksheet.
  • In Location, select G4.
  • Click OK.

Insert Pivot Table in the Existing sheet

  • PivotTable1 is created.

Pivot Table inserted in the dataset

  • Drag Brand into Rows and Variance into Values.

Customize the Pivot Table

  • Go to the PivotTable Analyze tab >> click Field, Items, & Sets  >> Calculated Field.

Insert the calculated table in the Pivot Table

  • In the Insert Calculated Field window, enter a name in Name and use the following formula in Formula.
=if(Variance<0,-1*Variance, Variance)
  • Click Add.
  • Click OK.

Insert a new field in the pivot table

This is the output.

Get absolute value for variance

The absolute values of the Variance column are displayed in the Sum of Absolute Variance column.


Method 7 – How to Get the Absolute Value Using the Power Query in Excel

Steps:

  • Select B4:E9 >> go to Data >> From Table/Range.

Select a range for power query

  • In the Create Table window, check My table has headers.
  • Click OK.

Check the range of the table

  • In the Power Query Editor, select Add Column.
  • Click Custom Column in General.

Add a new column in the power query

  • Enter a name in New column name.
  • Use the following formula in Custom column formula.
=if [Variance] < 0 the -[Variance] else [Variance]
  • Click OK.

Insert new formula for custom column

This is the Power Query window:

Get absolute value using power query

It displays the absolute values in the Absolute Variance column.


Method 8 –  Using a VBA Macro to Get the Absolute Values for a Large Excel Dataset

Steps:

  • Go to the Sheet Name and right-click.
  • Choose View Code.

Enter into vba module

  • In the VBA window, choose Module in the Insert tab.
  • Enter the following VBA code in the Module.
Sub Calculating_Absolute_Value()
Dim Variance, V_cell As Range
Set Variance = Application.InputBox(Prompt:="Select Input Range", Type:=8)
    For Each V_cell In Variance
        V_cell.Offset(0, 1).Value = Abs(V_cell.Value)
    Next V_cell
End Sub

Code Breakdown

  • Dim Variance, V_cell As Range

Declares two variables of the range type.

  • Set Variance = Application.InputBox(Prompt:=”Select Input Range”, Type:=8)

Sets the value of Variance using an InputBox of the range type.

  • For Each V_cell In Variance

              V_cell.Offset(0, 1).Value = Abs(V_cell.Value)

         Next V_cell

Applies a loop to each cell of Variance. The ABS function determines the absolute value for the V_cell and inserts that value into the next column of the same row. It moves to the next cell of V_cell.

Copy and paste vba code into the module

  • Run the VBA code by pressing F5.
  • Select E5:E9 in Input.
  • Click OK.

Select a range from the dataset

This is the output:

Get absolute value applying VBA code

The absolute values are displayed in the Absolute Variance column.


How to Get the Absolute Value in Excel: 5 More Examples

1. Calculate the Absolute Value of a Conditional Sum

The dataset contains two data series in columns B and C. To get the sum of values smaller than 0 in Series 1 and the sum of values greater than 0 in Series 2:

  • Enter the formula in F4:
=ABS(SUMIF(B5:B9,"<0")+SUMIF(C5:C9,">0"))

Get absolute for the conditional sum

Formula Breakdown

  • SUMIF(B5:B9,”<0″)

Determines the sum of values smaller than 0 in Series 1.

Result: -55

  • SUMIF(C5:C9,”>0″)

Determines the sum of values greater than 0 in Series 2.

Result: 50

  • ABS(SUMIF(B5:B9,”<0″)+SUMIF(C5:C9,”>0″))

determines the absolute value of the sum returned by the SUMIF functions.

Result: 5

Read More: Changing Negative Numbers to Positive in Excel


2. Calculate the Absolute Sum Value in an Array Formula

  • Enter the following formula in E11 to get the absolute sum of the Variance array.
=SUM(ABS(E5:E9))

Absolute sum for array formula

You can also use the formula below:

=SUMPRODUCT(ABS(E5:E9))

Read More: How to Sum Absolute Value in Excel


3. Find the Maximum/Minimum Absolute Value

  • Enter the following formulas to get the maximum and minimum values in E11 and E12.

To get the maximum value:

=MAX(ABS(E5:E9))

To get the minimum value:

=MIN(ABS(E5:E9))

Determine maximum and minimum absolute value


4. Calculate the Average of Absolute Values in Excel

  • Use the formula in E11:
=AVERAGE(ABS(E5:E9)) 

Average of absolute value


5. Calculate the Tolerance of the Variance

Steps:

  • Find the tolerance of the variance using the following formula in F5.
=(--(ABS(E5)<120))
  • Drag down the Fill Handle to see the result in the rest of the cells.

Formula to detect cells based on toleranceIf the variance is below the tolerance level 1 is displayed. Otherwise, 0.

  • Select F5:F9 >> go to Conditional Formatting >> Icon Sets >> choose a symbol in Indicators.

Apply conditional formatting to mark the tolerance values

This is the output.

Marked the tolerance values

 

Read More: How to Calculate Absolute Difference between Two Numbers in Excel


Frequently Asked Questions

1. Can I get the absolute value of a complex number in Excel?

Ans: Yes, use the ABS function:  ABS(x)x is the complex number.

2. Can I use the ABS function to calculate the distance between two numbers in a number line?

Ans: The distance between two numbers in a number line is the absolute value of the difference between two numbers. You can use the following formula: ABS(A1-A2).


Download Practice Workbook

Download the practice workbook.


Related Articles


<< Go Back to Excel ABS Function | Excel Functions | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Mehedi Hasan Shimul
Mehedi Hasan Shimul

Md. Mehedi Hasan, with a BSc in Electrical & Electronic Engineering from Bangladesh University of Engineering and Technology, holds a crucial position as an Excel & VBA Content Developer at ExcelDemy. Driven by a deep passion for research and innovation, he actively immerses himself in Excel. In his role, Mehedi not only skillfully addresses complex challenges but also exhibits enthusiasm and expertise in gracefully navigating tough situations, emphasizing his steadfast commitment to consistently deliver exceptional and quality content.... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo