2023-10-17 23:36:14 +08:00
|
|
|
[discrete]
|
2023-05-24 05:01:08 +08:00
|
|
|
[[esql-mv_median]]
|
|
|
|
=== `MV_MEDIAN`
|
|
|
|
Converts a multivalued field into a single valued field containing the median value. For example:
|
|
|
|
|
2023-06-12 22:37:45 +08:00
|
|
|
[source.merge.styled,esql]
|
2023-05-24 05:01:08 +08:00
|
|
|
----
|
|
|
|
include::{esql-specs}/math.csv-spec[tag=mv_median]
|
|
|
|
----
|
2023-06-12 22:37:45 +08:00
|
|
|
[%header.monospaced.styled,format=dsv,separator=|]
|
2023-05-24 05:01:08 +08:00
|
|
|
|===
|
|
|
|
include::{esql-specs}/math.csv-spec[tag=mv_median-result]
|
|
|
|
|===
|
|
|
|
|
|
|
|
It can be used by any numeric field type and returns a value of the same type. If the
|
|
|
|
row has an even number of values for a column the result will be the average of the
|
|
|
|
middle two entries. If the field is not floating point then the average rounds *down*:
|
|
|
|
|
2023-06-12 22:37:45 +08:00
|
|
|
[source.merge.styled,esql]
|
2023-05-24 05:01:08 +08:00
|
|
|
----
|
|
|
|
include::{esql-specs}/math.csv-spec[tag=mv_median_round_down]
|
|
|
|
----
|
2023-06-12 22:37:45 +08:00
|
|
|
[%header.monospaced.styled,format=dsv,separator=|]
|
2023-05-24 05:01:08 +08:00
|
|
|
|===
|
|
|
|
include::{esql-specs}/math.csv-spec[tag=mv_median_round_down-result]
|
|
|
|
|===
|
|
|
|
|