If you are performing a query, then you can use the resulting array of items:
-
Sort the array of items by the field that you want the median value of.
-
Find the middle of the array - (array length / 2)
-
Return the number at the midpoint if the length of the array is odd, otherwise return the average of the two middle numbers.