Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

tofernandez
New Contributor

Calculating the distance between elements + Counting the # of elements within a specific range

Hello, how are you?

I have a list of shops with their corresponding latitude and longitude values (in a decimal format) and I'd like to calculate the amount of shops in the same city located within 1 kilometer for each one of them. I've managed to do this in Excel in a very homemade and manual way but I need to automate it to be able to work with bigger data.

The list contains the following fields:

Shop name     Shop ID     LATITUDE     LONGITUDE

Basically, I'd like to know for every shop what the 'shop density' around it is. Distances between the elements aren't too big, so the Pythagorean distance formula will do.

Any kind of help is appreciated.

Thank you.

2 Replies

Re: Calculating the distance between elements + Counting the # of elements within a specific range

See this post: Re: distance between two coordinates

Or maybe this one: WGS84 Compliant Great Circle Distance Calculation


talk is cheap, supply exceeds demand
tofernandez
New Contributor

Re: Calculating the distance between elements + Counting the # of elements within a specific range

Thank you very much. I modified the first one and it worked just fine. I created the following expression which displayed the "shop density" for each shop:

sum(if(Distance<[insert distance in kilometers],1,0))

Community Browser