This tutorial will show how to calculate Manhattan distance in Excel. From the name, we can get an assumption that it is named after the famous city Manhattan in the USA. This feature of calculation is applicable not only in generic mathematics but also in statistics. To illustrate the concept of this article, we will use unique datasets. So, you will get a clear overview of the Manhattan distance calculation. Let’s start the discussion of this article.
What Is Manhattan Distance?
The Manhattan distance is a measure that calculates the distance between two points as the sum of their Cartesian coordinates’ absolute differences. To put it another way, it is the total sum of the differences between the x and y coordinates. We can use the following formula to calculate the Manhattan distance between two vector points A and B:
Here, j is the jth item in each vector.
The Manhattan distance refers to how much the two vectors are different from one another.
How to Calculate Manhattan Distance in Excel: 2 Suitable Ways
Throughout this article, we will demonstrate 2 suitable ways to calculate the Manhattan distance in Excel. We will consider 2 different scenarios to calculate the Manhattan distance. The first method will depict 2D Manhattan distance and the second one will depict 3D Manhattan distance.
1. Use ABS Function to Calculate Manhattan Distance in Excel
First and foremost, we will use the ABS function to calculate the Manhattan distance in Excel. The ABS function in Excel returns the absolute value of a number. It makes negative numbers into positive numbers. But, it doesn’t make any changes to positive numbers. Assume, we have the following dataset. The dataset contains different coordinates of two points A and B. We will calculate the Manhattan distance between these two points with the ABS function.
Let’s see the steps to implement this method.
- To begin with, select cell D5.
- In addition, insert the below formula in that cell:
- Press Enter.
- As a result, we get the absolute distance between the first two Coordinates of A and B.
- Furthermore, drag the Fill Handle tool from cell D5 to D9.
- So, we get results like the following image.
- Then, select cell D11.
- After that, type the following formula in that cell:
- Hit Enter.
- Finally, we get the value of Manhattan distance in cell D11.
2. Calculate 3D Manhattan Distance in Excel
This method will demonstrate how to calculate 3D Manhattan distance in Excel. Suppose We have a dataset like the following. The dataset contains two points A and B. The coordinates of these two points are:
A = (6.25, 4.75, 5.25)
B = (8, 8, 1)
We can see that the points are in 3D format. Here, we want to calculate the Manhattan distance between these two 3D points.
So, follow the below steps to perform this action.
- Firstly, select cell C9.
- Secondly, type the following formula in that cell:
- Now, press Enter.
- Lastly, we can see the value of Manhattan distance in cell D11.
Download Practice Workbook
You can download the practice workbook from here.
In conclusion, this tutorial is a complete guide to calculating the Manhattan distance in Excel. Also, Use the practice worksheet that comes with this article to put your skills to the test. If you have any questions, please leave a comment below. Our team will try our best to respond to you as quickly as possible.