mv_median.asciidoc 841 B

123456789101112131415161718192021222324252627
  1. [discrete]
  2. [[esql-mv_median]]
  3. === `MV_MEDIAN`
  4. Converts a multivalued field into a single valued field containing the median value. For example:
  5. [source.merge.styled,esql]
  6. ----
  7. include::{esql-specs}/math.csv-spec[tag=mv_median]
  8. ----
  9. [%header.monospaced.styled,format=dsv,separator=|]
  10. |===
  11. include::{esql-specs}/math.csv-spec[tag=mv_median-result]
  12. |===
  13. It can be used by any numeric field type and returns a value of the same type. If the
  14. row has an even number of values for a column the result will be the average of the
  15. middle two entries. If the field is not floating point then the average rounds *down*:
  16. [source.merge.styled,esql]
  17. ----
  18. include::{esql-specs}/math.csv-spec[tag=mv_median_round_down]
  19. ----
  20. [%header.monospaced.styled,format=dsv,separator=|]
  21. |===
  22. include::{esql-specs}/math.csv-spec[tag=mv_median_round_down-result]
  23. |===