Skip to main content
Question

distance between two addresses

  • September 25, 2019
  • 0 replies
  • 669 views

Forum|alt.badge.img+6
I am trying to calculate the distance between two addresses.  I put the below formula in but came up with a distance of 5000 and it should be 3. 

var number OriginLat = [LatitudeVendor];
var number OriginLong = [LongitudeVendor];
var number DestLat = [LatitudePlant];
var number DestLong = [LongitudePlant];
var number Distance = Round(((69*($OriginLat - $DestLat))^2 + (53*($OriginLong - $DestLong))^2)^0.5);

If($OriginLat =0 or $DestLat=0,0,$Distance)



------------------------------
Sarah Burres
------------------------------

MarkShnierYou
Forum|alt.badge.img+22
  • Quickbase Alumni
  • September 25, 2019
Your screen shot shows in fact 1,547 miles not 5,000.  It's impossible with the coordinates in the screen shot to only be three miles apart.  They are very far apart as they are very different.  I think that your source data is incorrect.  

"My" formula is correct.

------------------------------
Mark Shnier (YQC)
Quick Base Solution Provider
Your Quick Base Coach
http://QuickBaseCoach.com
markshnier2@gmail.com
------------------------------

Forum|alt.badge.img+8
  • Quickbase Alumni
  • February 5, 2025

I've just stumbled on this thread as I'm trying something similar. I can get the coordinates to work and the field is calculating. However, I'm getting something different than what maps is showing me. For example, the formula is calculating a distance of 70miles for one example, but when I measure the distance on Google Maps it gives me 66 miles. Is there something in the above formula that is preventing us from getting an accurate number? 

What Quickbase says:

What Google Maps measurement says:

 


MarkShnierYou
Forum|alt.badge.img+22
  • Quickbase Alumni
  • February 5, 2025

The formula is just an approximation and certainly is not driving distance, but crow flies distance. It also works best at he geographic center of the USA and will utterly fail near the north and south poles (not much demand for distances for Polar Bears or Penguins). It's best used to rank results according to approximate distance.  The "exact" formula would require advanced trigonometric non Euclidian functions which do not exists in native Quickbase.  

But all kidding aside, if you are using it mostly in certain part of he world, it can be adjusted to be better as those values of 69 and 53 refer to the distance between the integer Lat and Long lines in your typical locale. 

 


Forum|alt.badge.img+8
  • Quickbase Alumni
  • February 5, 2025

Since leaving that comment, we've figured out that we wouldn't be able to find anything specific and can manually verify if the distance shown in Quickbase is within a certain amount on either side of our limit! We would have had to do that anyway so it's not a huge deal that this is an approximation and nothing super exact. Thank you for the reply!


Forum|alt.badge.img+8
  • Quickbase Alumni
  • February 6, 2025

We are calculating distance between a pilot's home address and their assigned base and they could live anywhere so it's all over the place.


Forum|alt.badge.img+15
  • Quickbase Alumni
  • February 6, 2025

Hannah,

Google has this tool:

https://developers.google.com/maps/documentation/distance-matrix/overview

I suspect you can use a Pipeline to hit it and then return an answer to your record in QB.

 


Forum|alt.badge.img

Hi Sarah,

I noticed this request today and I wanted to suggest QB Maps from Juiced Technologies. This Add-on has a feature which will allow you to accomplish exactly what you are hoping for out of the box.

https://www.juicedtech.com/qb-maps

If you would like, we can schedule a demo to show you the functionality.

Matthew Tillinghast
matthewt@juicedtech.com 

 


MarkShnierYou
Forum|alt.badge.img+22
  • Quickbase Alumni
  • February 6, 2025

Another tip is that if you need to double check a single record, there is syntax to click a button to have Google display the driving directions and distance.

 

 

List("/", 
"https://www.google.com/maps/dir",
URLEncode([From Address]),
URLEncode([To Address])
)


Forum|alt.badge.img+8
  • Quickbase Alumni
  • February 7, 2025

Thank you everyone for the suggestions! We use as the crow flies distance to be objective so a driving distance wouldn't be as helpful. I am unable to get cost approval for additional resources as we have a third party implementation partner already. I will reach out to them to see if they have any suggestions!


MarkShnierYou
Forum|alt.badge.img+22
  • Quickbase Alumni
  • February 7, 2025

Not to beat us to death, but as an intellectual exercise, the formula could be improved by having a look up table to adjust the constant in the formula of 54 to be the number 45 where the latitude of the Base was up at the 49th parallel in the north near Canada (yes we are still a separate country up here and not yet the 51st state), and would be adjusted to a value of 60 for a Base down in the south near New Orleans, home of 2025 EMPOWER.  Obviously the table could be loaded with say 100 values representing the range of latitudes in the USA.

Chat GPT is useful for doing the legwork on these values.


bensimon
Forum|alt.badge.img+14
  • Quickbase Alumni
  • February 12, 2025

MarkShnier__You is referencing Pythagorus, making Canada 51st state plugs, and dropping promos for Empower 2025 all in one discussion thread. All the while providing help in how to accurately capture distance between two points via a formula in Quickbase.

Qrew Legend indeed...

Thank you to everyone who contributed to this.