Table.MinN

The function retrieves the smallest row(s) from a table based on the comparison criteria provided. Upon sorting the rows, the countOrCondition parameter is required to refine the results. It should be...

Syntax

Table.MinN(table as table, comparisonCriteria as any, countOrCondition as any) as table

About

The function retrieves the smallest row(s) from a table based on the comparison criteria provided. Upon sorting the rows, the countOrCondition parameter is required to refine the results. It should be noted that the sorting algorithm does not ensure a consistent sorted outcome. The countOrCondition parameter can be specified in two ways: If a number is given, a list containing up to that number of items in ascending order will be returned. Alternatively, if a condition is specified, a list of items that initially satisfy the condition will be returned. Subsequently, if an item no longer fulfills the condition, it will not be included in the final result.

Explanation

Example 1: Identify the row in the table where the value in column [a] is the smallest and meets the condition [a] < 3. The rows are arranged in order before applying the filter. Usage Power Query M Table.MinN( Table.FromRecords({ [a = 2, b = 4], [a = 0, b = 0], [a = 6, b = 4] }), "a", each [a] < 3 ) Output Table.FromRecords({ [a = 0, b = 0], [a = 2, b = 4] }) Example 2: Locate the row in the table where the value in column [a] is the smallest and meets the condition [b] < 0. The rows are sorted before the filter is applied. Usage Power Query M Table.MinN( Table.FromRecords({ [a = 2, b = 4], [a = 8, b = 0], [a = 6, b = 2] }), "a", each [b] < 0) Output Table.FromRecords({})