> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# Distance

> Use the Sigma Distance function to calculate the minimum distance between two geographies, in specified units.

The **Distance** function calculates the minimum distance between two geographies, in specified units.

This function isn't compatible with all data platform connections. To check if your connection supports it, see [Supported data platforms and feature compatibility](/docs/region-warehouse-and-feature-support#supported-data-platforms-and-feature-compatibility).

## Syntax

```
Distance(units, geog1, geog2)
```

The function arguments are:

<dl>
  <dt>
    units
  </dt>

  <dd>
    Required
  </dd>

  <dd>
    The unit of measurement for the distance.
  </dd>

  <dd>
    Valid values are 

    <code>"kilometers"</code>

    , 

    <code>"meters"</code>

    , and 

    <code>"miles"</code>

    .
  </dd>

  <dt>
    geog1
  </dt>

  <dd>
    Required
  </dd>

  <dd>
    First geography of the pair between which we calculate the distance.
  </dd>

  <dd>
    Must be in valid Geography format.
  </dd>

  <dd>
    To work from known latitude and longitude values, use the 

    [MakePoint](/docs/makepoint)

     or 

    [MakeLine](/docs/makeline)

     functions.
  </dd>

  <dt>
    geog2
  </dt>

  <dd>
    Required
  </dd>

  <dd>
    Second geography of the pair between which we calculate the distance.
  </dd>

  <dd>
    Must be in valid Geography format.
  </dd>

  <dd>
    To work from known latitude and longitude values, use the 

    [MakePoint](/docs/makepoint)

     or 

    [MakeLine](/docs/makeline)

     functions.
  </dd>
</dl>

## Examples

```
Distance("kilometers", [Coordinates], MakePoint(0, 0))
```

```
Distance("miles", [Coordinates], MakePoint(0, 0))
```

The **Distance** function returns the following values for the **Coordinates** column, when specifying distance in either kilometers or miles from coordinates (0, 0):

![Example of the Distance function, showing the distance in kilometers and miles from a set of coordinates to the origin](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/17267c36d75e49f8409fd78a56cdba78827d7344a2ae908cb4ec9f833e2089ea/assets/docs-images/19770ed-function-distance-example.png)

On Databricks connections, values might differ slightly from those shown in the examples. This is because Databricks represents earth using the [WGS 84 ellipsoid](https://en.wikipedia.org/wiki/World_Geodetic_System), while other connections assume a perfect sphere.

## Related resources

* [Area](/docs/area)
* [Perimeter](/docs/perimeter)
* [Geography functions](/docs/geography-functions)