basically, I have to “Add the Distance in Km” then I have to Label the Distances of foreign countries in table afterward I have to label distance according to categories like the following requirements which are as under:
within 15km from City center => Lokal Customers
From 15 to 50 km from city center => Distant Customer
From 50 km but within Germany => Online shopping Customer
Not in Germany => Foreign Customer
Waiting for quick response. Thank you in advance.
Regards,
Q

Hi,
First you have to use a “Math Formula” or “Column Expressions” node to calculate the distance by using the following formula:

dlon = lon2 - lon1
dlat = lat2 - lat1
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2( sqrt(a), sqrt(1-a) )
distance = R * c (where R is the radius of the Earth - 6,371,000 m)

Then use a “Rule Engine” node to label the output.

This formula calculates the distance in km. You have to replace [baseLatitude] and [baseLongitude] with the actual values of your base location. Then the rest of formula will go fine (I hope…).

Which longitude and latitude are referring to the location of your organization (the location you want to calculate the distance of customers from)? Use them in place of [base…]
and use the other ones (the location of the customers) in place of $lon…$

For example if the “latitude” and “longitude” columns are referring to the location of your organization and the “lat” and “Lon” columns are referring to your customers’ location then the formula should be:

The distance is obviously already in the last column. It’s 0 (zero) in the screenshot above this post, because both coordinates are equal. So, what exactly is the problem?

I updated the formula. There was a problem in placing the parentheses. (Be aware that I used “latitude” and “longitude” columns as base location and then I used “lat” and “Lon” columns as customers’ location)

Now you can use a “Rule Engine” node to label the output.

I’m not sure if I’m getting you clearly but I can say that you need the coordination of the shopping center or anywhere that you consider as base location and the coordination of the customers’ location. Then you can find the distance between these 2 by using the formula I provided in a “Math Formula” node. And after that you can easily use the “Rule Engine” node to put labels on the output data based on the distance you calculated.

Thank you for making jokes, anyways as I mentioned before that I want to solve this requirement as under:
within 15km from City centre => Lokal Customers
From 15 to 50 km from city centre => Distant Customer
From 50 km but within Germany => Onlineshopping Customer
Not in Germany => Foreign Customer

Distance I know its there but when I used rule engine the results are not coming. Thank you