Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
krish2459
Creator
Creator

50 km radius in qliksense maps

Hi,

I'm aving a map as below and when when i click on site(red dot) the map should zoom into 50 km radius.

 

Let me know how to get this.

 

krish2459_0-1597392390259.png

 

Thanks...

 

1 Solution

Accepted Solutions
Steven_Haught
Creator III
Creator III

This can be done with the help of some variables and some math.

Create a variable: vLAT and vLONG

Place the correct lat and long field in each variable. Just the field name.

Use the following formula in your ID for the point or bubble layer:

If(GetSelectedCount([Store ID])>0,

IF(Round(ACOS(SIN(customer lat field*Pi()/180)*SIN($(vLAT)*Pi()/180)+COS(customer lat field*Pi()/180)
*COS($(vLAT)*Pi()/180)*COS(($(vLONG)*Pi()/180)-(customer long field*Pi()/180)))*3963)
<=31.07
,[Cust ID])

,[Cust ID])

Notes:

It appears the store and customer field labels were backwards in your sample data, this is why I don't have the field labels above. 

The 31.07 is to get approx. Miles to Kilometers as the formula is for miles. 

Steven_Haught_3-1597437735336.png

 

View solution in original post

14 Replies
krish2459
Creator
Creator
Author

I'm explaining more as below.

when user clicks on red dot (store ID) he wants to see all the customers(small dots) with in 50 km range.

ggEumdr process.PNG

Steven_Haught
Creator III
Creator III

This can be done with the help of some variables and some math.

Create a variable: vLAT and vLONG

Place the correct lat and long field in each variable. Just the field name.

Use the following formula in your ID for the point or bubble layer:

If(GetSelectedCount([Store ID])>0,

IF(Round(ACOS(SIN(customer lat field*Pi()/180)*SIN($(vLAT)*Pi()/180)+COS(customer lat field*Pi()/180)
*COS($(vLAT)*Pi()/180)*COS(($(vLONG)*Pi()/180)-(customer long field*Pi()/180)))*3963)
<=31.07
,[Cust ID])

,[Cust ID])

Notes:

It appears the store and customer field labels were backwards in your sample data, this is why I don't have the field labels above. 

The 31.07 is to get approx. Miles to Kilometers as the formula is for miles. 

Steven_Haught_3-1597437735336.png

 

venkatadineshqv
Contributor II
Contributor II

Hello Steven, tried using the formula. It isn't working for me. Tried breaking down the formula and it is returning some values as expected but as formula all together it throwing zero even though there are some zip codes near by. Can you please advise?

Steven_Haught
Creator III
Creator III

@venkatadineshqv  

do you have lat long info for the zip code? Can you show your formula or some information on your set up? 

venkatadineshqv
Contributor II
Contributor II

Yes I have lat long details for the zip codes and I have used the formula same as you have shared above.

Steven_Haught
Creator III
Creator III

@venkatadineshqv 

What is your second set of Lat Long data? 

venkatadineshqv
Contributor II
Contributor II

I don't understand what do you meant by second set, can you please elaborate. Just for your understanding my requirement here is to select a zip code and see what all zip records that fall under 50 mile radius around it. Can you please advise?

Steven_Haught
Creator III
Creator III

@venkatadineshqv 

This formula is actually using two separate lat long sets to calculate the distance. In the above example, store data and customer data. The variable contained the store data. The  variable will hold the single store lat and long in the formula and then assess the other points in order to see the 50km radius. So you need two separate dimensions and lat long sets. You can use the same ones you just need to create them as unique sets in your load. Hope that makes sense! 

JordyWegman
Partner - Master
Partner - Master

@Steven_HaughtThanks for the formula, big help!

 

@venkatadineshqv, I see you're struggling. Make sure that you have done the following:

  1. Create a field in the following format: [ {longitude} , {latitude} ] as ZipLocation
  2. Add the ZipLocation as a point layer in your maps object
  3. Replace the GetSelectedCount with GetPossibleCount in the formula of @Steven_Haught. Because this formula only works if your dimension in the point layer is the same as the one in the formula. If they are different, use the possible one.

If this is not working please show us the configuration of your maps object and a bit of the data.

Jordy

Climber

Work smarter, not harder