Hi, in this article we will learn how to find absolute value in google sheets.
So, if you are interested in mathematics, you must have heard the term absolute value, if not let me clarify what it means. Most people think that the absolute value means the actual value without any leading decimal points, but it’s not correct. The absolute value means the actual value without any negative or positive sign. We have values like -1 and 1. Both of these values are opposite to each other, now -1 is not an absolute value. To make this an absolute value we will have to remove the minus or negative sign from it. so, it will become a simple 1 with no sign. This is called absolute value. A value without any sign is an absolute value.
But this is very simple, I mean why I am teaching you this? you can easily remove minus sign manually by yourself and make your values absolute.
But what if you have 1000 rows of data and you need to convert all of them into their absolute values, what will you do? will you convert them manually? Of course not.
So, in this article, we will talk about three easy ways to find absolute values of a large dataset in a few seconds.
Use case of finding absolute value in Google Sheets
We sometimes have a lot of negative values in a large data set, and for some reason, we need to have a sum of them. The problem is that we don’t know how many positive and negative values are there, it’s mixed data and we want to know the overall sum of all the values, what will we do? shall we check them and separate positive and negative values? Surely no. In this article, you will learn how to solve such problems, and therefore you need to learn how to find absolute value in google sheets.
How to find absolute value in Google Sheets
To step-by-step learn how to find absolute value in google sheets, we have some examples for you. Some randomly written data sets are problem statements and we will use our methods to solve them practically step by step. So, let’s get into it and practically learn how to find absolute value in google sheets.
How to find absolute value in Google Sheets – Using ABS Function
ABS is a built-in function that stands for ABSOLUTE, it simply takes a single value or cell and converts it into its original absolute value. This is the simplest function in google sheets because it’s very straight forward it takes only a single value and returns an absolute value in another cell, note that this method is not mutable, so it does not change our original data.
Let’s see how this function can help us to find absolute value in google sheets.
Step 1
Some random data
Step 2
Write ABS function
Step 3
Pass cell reference or value
Step 4
Press Enter Key, and you’re done.
Note: This function cannot receive multiple cells or a range.
To solve this problem, we will use Array Formula along with the ABS function.
How to find absolute value in Google Sheets – Using ARRAY FORMULA with ABS Function
In this section, we will learn how to find absolute value in google sheets using an array formula with ABS function to find absolute value for multiple cells or cell ranges. The previous ABS method was not sufficient to work on multiple cells or range, although we have the option to drag and copy the formula but why do we copy when we have a more prominent solution for multiple cells and range. This method allows you to pass multiple cell ranges to a formula and get instant results for a big data set.
To understand this please see the simple steps below
Step 1
Some big data sets (multiple rows and columns)
Step 2
Write the ArrayFormula with ABS function in it
Step 3
Pass multiple data cells or cell ranges
Step 4
Hit Enter and you’re done.
You see how easily we got the desired results for multiple rows and columns using a simple Array formula along with the ABS function.
Now, we will some more methods to find absolute value in google sheets
How to find absolute value in Google Sheets – Using IF Statement
IF statement is a very powerful logical statement in programming, it’s used in almost every programming language to perform a certain action in a certain situation. We will IF statement and learn how to find absolute value in google sheets.
First, understand how we will use the IF statement to find absolute value in google sheets.
We will check all the values in a range, if found a value is less than 0 (negative value), we will multiply it by -1 (it will become a positive value), and else if we find a value greater or equal to 0, we will skip it.
So, using the above logic we will get a list of absolute values.
Step 1
Sample data
Step 2
Write the IF statement in the adjacent column
Step 3
Define IF condition
Step 4
Define ELSE condition
Step 5
Press Enter key, and you’re done
This is how we can use simple logic to convert our values into absolute values. This is how you think programmatically and use simple functions to do anything.
Note: This method is also non-mutable, so it will not change your original data.
How to find absolute value in google sheets – Using APP SCRIPT
App Script or Google Script is a powerful tool to make custom functions and methods programmatically by writing code. We will learn how to find absolute value in google sheets using App Script.
So, the logic is going to be the same as we used in the IF statement previously. But this method is mutable and it will change the original data.
The code to find absolute value is below:
function findAbsolute() {
var app=SpreadsheetApp;
var ss=app.getActiveSpreadsheet();
var activeSheet=ss.getActiveSheet();
var range=activeSheet.getActiveRange();
var values=range.getValues();
var value;
for (var i in values){
var row=values[i]
for (var j in row) {
value=row[j]
if (value<0){
row_num=parseInt(i)+1;
col_num=parseInt(j)+1;
console.log(value)
console.log(row_num, col_num)
activeSheet.getRange(row_num+1,col_num).setValue(value*(-1));
}
}
}
}
Copy and paste this code into your app script code editor and save it into macros.
Step 1
Copy the code
Step 2
Go to your google sheet file
Step 3
Go to Extension > Apps Script
Step 4
Remove everything, and paste this code
Step 5
Click on Save and then Run
Step 6
Back to your sheet
Step 7
Go to Extensions > Macros > import Macro
Step 8
Now you can see it added to macros
Step 9
To run this Script Go to Extensions > Macros > Click on the project name
Note that this method is mutable means it can change the original data sometimes.
Notes
- The best method with no complexity is the Array Formula with ABS function
- Any method can be used you just need to know your situation and use the best fit for it
- IF else condition is very effective to perform such calculations
- You should always know your method if it’s mutable or not, because sometimes you need to change the data, and sometimes you just want a copy of the original data with certain changes.
- Most of the methods are non-mutable, they don’t change the original data, in this article we learned four methods and all are mutable, if we talk about the app script method, sometimes its mutable and sometimes it gives you a copy of the original data after converting into an absolute value.
FAQ
Why do we find absolute value in google sheets?
We sometimes need to have some temporary calculations on our data but we need them into their original value, their base value, on their actual value. The actual value is always positive, negative values can not be actual values because they are not values they are only showing the proportion of any value. So we many times need to have actual values, for this reason, we find absolute value in google sheets, it can be said as actual value, base value, and original value as well. Also, you should know that some people refer to absolute value with the zero decimal points value. You will get confused when someone will say that removing decimal points makes a value an absolute value. It’s just a convention, don’t worry about it.
Conclusion
The final thoughts on how to find absolute value in google sheets, this article covered four methods to find absolute value in google sheets. It’s a basic conversion you can say we just remove the leading minus from a number to make it an absolute value. You can directly tell if a value is absolute or not, and even you can make any value into its absolute form manually by removing the minus sign, this article was meant to teach how it’s done programmatically, how can we do it logically for a big data set, for some data we can do it manually, but in today’s we don’t have small data, we always work on large data and thus we need such methods and formulas to solve these problems within a few seconds.
I hope you guys enjoyed the article and you have learned how to find absolute value in google sheets. Thank you, see you soon in the next tutorial.