﻿---
title: ES|QL MV_MEDIAN_ABSOLUTE_DEVIATION function
description: 
url: https://www.elastic.co/elastic/docs-builder/docs/2990/reference/query-languages/esql/functions-operators/mv-functions/mv_median_absolute_deviation
products:
  - Elasticsearch
---

# ES|QL MV_MEDIAN_ABSOLUTE_DEVIATION function
## Syntax

![Embedded](https://www.elastic.co/elastic/docs-builder/docs/2990/reference/query-languages/esql/images/functions/mv_median_absolute_deviation.svg)


## Parameters

<definitions>
  <definition term="number">
    Expression that can be null, a single value, or multiple values.
  </definition>
</definitions>


## Description

Converts a multivalued field into a single valued field containing the median absolute deviation.  It is calculated as the median of each data point’s deviation from the median of the entire sample. That is, for a random variable `X`, the median absolute deviation is `median(|median(X) - X|)`.
<note>
  If the field has an even number of values, the medians will be calculated as the average of the middle two values. If the value is not a floating point number, the averages are rounded towards 0.
</note>


## Supported types


| number        | result        |
|---------------|---------------|
| double        | double        |
| integer       | integer       |
| long          | long          |
| unsigned_long | unsigned_long |


## Example

```esql
ROW values = [0, 2, 5, 6]
| EVAL median_absolute_deviation = MV_MEDIAN_ABSOLUTE_DEVIATION(values), median = MV_MEDIAN(values)
```


| values:integer | median_absolute_deviation:integer | median:integer |
|----------------|-----------------------------------|----------------|
| [0, 2, 5, 6]   | 2                                 | 3              |