# Distance Calculation Metric

When and how to create an distance calculation metric on Locale

We use the distance calculation metric when we have to calculate the distance between any two points where a particular event has occurred.

For example:

- What is the distance between short distance trips?
- What is distance between orders started and orders completed?
- What is the distance between the users and the nearest bike/nearest dock station?

**✨Note: This distance calculated is called the haversine distance and not the route distance. The haversine formula determines the distance between two points on a sphere given their longitudes and latitudes.**

- Navigate to the selected dashboard and click the
**Edit Console**button to enable editing mode, which allows the user to add a metric. - In the
**Metric studio,**click on the**Add New Metric**.

Metric Studio: Add New Metric

- When the window appears, select Metric Type to begin visualising the specified metric. In this case, we select the
**Distance Calculation Metric.**

Choosing distance calculation metric

Different fields required

**Metric Name****Entity**- These are components of your business that have both a location and time component. It could be users, riders, stores, and so on. This metric can only be calculated on any entities with both a starting and an ending event.

For example, trip (start and completed), orders( start and completed) and so on.

**Start Event**- This is the event which will serve as the starting point for the distance calculation. This could be the starting point of a trip, the ending point of a trip, starting point of an oder pick up and so on.**End Event**- This is the event which will serve as the ending point for the distance calculation. This could also be the starting point of a trip, the ending point of a trip, starting point of an oder pick up and so on.**Aggregation:**This field appears as soon as we choose the event property Here we enter the mode of aggregation, i.e how we want the data to be processed. Here are a few modes of aggregation that the users can choose:- Count
- Unique count
- Average
- Minimum
- Maximum
- Median
- Sum

**Event to visualize:**This is the event that will be shown on the map. The users can choose to visualize the "Start event" or "End Event". For example, if you want to visualize the distance taken either from the starting point of the trip or the ending point of the trip.

**✨Note: Event to Visualize drop down of "start" or "end" will be available only for hex console and not trips console.**

Here's an example metric that we can create using distance calculation metric:

Metric name: Avg Trip Distance

Entity: Trips

Start Event: Trip Start

End Event: Trip End

Aggregation: Average

Event to visualize:Trip Start

Sample metric

Last modified 1yr ago