List.Median

This function retrieves the middle item from the list provided. If the list does not contain any non-null values, the function will return null. In case of an even number of items, the function will r...

Syntax

List.Median(list as list, optional comparisonCriteria as any) as any

About

This function retrieves the middle item from the list provided. If the list does not contain any non-null values, the function will return null. In case of an even number of items, the function will return the smaller of the two middle items unless the list consists only of datetimes, durations, numbers, or times, in which case it will return the average of the two items.

Explanation

Calculate the median of the set {5, 3, 1, 7, 9} using Power Query M function Mpowerquery-mList.Median({5, 3, 1, 7, 9}). The result will be 5.