median

open infix fun <T : Number> Field<Into, T>.median(value: Value<From, Number?>)(source)
open infix fun <T : Number> KProperty1<Into, T>.median(value: Value<From, Number?>)(source)

Returns an approximation of the median, the 50th percentile, as a scalar value.

The median is computed with the t-digest algorithm, which computes an approximation. The result may vary, even on the same dataset.

Example

class User(
val name: String,
val balance: Int,
)

class Result(
val medianBalance: Double,
)

users.aggregate()
.group {
Result::medianBalance median of(User::balance)
}

External resources