The functions available in the formula builder doesn’t include trigonometric functions like SINE and COSINE. Some industries want to use longitude and lattitude to calculate distance, but without these functions, it can’t be done.
The ability to calculate distance would enable location-based routing. If we had the location of a lead and the location of our offices, we could calculate the distance between the lead and the offices and route the lead to the geographically nearest office. The first thing we need to accomplish this is the formulas. (It can be done easily in Excel, which does have these formulas.)
I would love to see these formulas added to the formula builder in Datasets, or the formula builder beta in custom reports.
You’re spot on that HubSpot’s formula builder doesn’t currently support trig functions like SINE or COSINE, which makes distance-based routing tough to pull off natively.
The fastest way around this is to handle the calculation outside HubSpot with Coefficient’s certified 2-way sync between HubSpot and Google Sheets or Excel.
Here’s how you can set it up in about 5 minutes.
Step 1: Connect HubSpot to your spreadsheet
- Install Coefficient in Google Sheets or Excel.
- Use the HubSpot connector to pull in the lead and office location data you need (lat/long or addresses you’ve geocoded).
Step 2: Calculate distance with trig formulas
- In Sheets or Excel, you can use the Haversine formula (which relies on SIN, COS, etc.) to calculate distances.
- Coefficient also has an AI Assistant in Google Sheets that can write the formula for you—just tell it “calculate distance in km between two lat/long columns.”
Step 3: Build your routing logic
- Add a column that assigns the nearest office based on the distance calculation.
- Validate with a quick pivot or filter to make sure leads are being routed correctly.
Step 4: Push results back into HubSpot
- With Coefficient’s 2-way sync, you can write the assigned office (or even the calculated distance if you want) back to HubSpot as a property.
- From there, use workflows to route leads automatically.
Step 5: Optional — keep it live
- Set a refresh schedule (hourly, daily, etc.) so the routing data is always up to date.
That way you bypass the formula limitations in HubSpot while still keeping all the results stored and actionable inside HubSpot.
I work at Coefficient, so happy to answer any questions if you have any!