Table.MinN
TableReturns the N rows with the lowest values according to the given comparison criteria.
Syntax
Table.MinN(table as table, comparisonCriteria as any, countOrCondition as any) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
table | table | Yes | The table to search. |
comparisonCriteria | any | Yes | A column name, list of column names, or comparer function defining the sort order. |
countOrCondition | any | Yes | A number specifying how many bottom rows to return, or a condition function. |
Return Value
table — A table containing the rows with the N lowest values.
Remarks
Table.MinN returns the bottom N rows by the specified comparison criteria, ordered from lowest to highest. When countOrCondition is a number, it returns exactly that many rows. When it is a function (predicate), it returns rows from the bottom of the sorted order (ascending) while the predicate remains true — stopping at the first row that fails the condition.
Table.MinN is the counterpart of Table.MaxN and is useful for bottom-N analysis — finding the N lowest salaries, the cheapest products, the earliest orders, or all values below a threshold. It is equivalent to Table.FirstN(Table.Sort(table, {criteria, Order.Ascending}), N).
When using a condition function, the condition is applied in ascending sort order. The function returns rows from the lowest value upward and stops at the first row that fails the predicate. This is a leading contiguous behavior — rows are not filtered globally; scanning stops at the first non-matching row.
Examples
Example 1: Bottom 3 products by price
let
Products = #table(
type table [ProductID = number, ProductName = text, Category = text, Price = number, InStock = logical],
{{1,"Widget A","Widgets",25.00,true},{2,"Gadget B","Gadgets",50.00,true},
{3,"Widget C","Widgets",15.00,false},{4,"Gadget D","Gadgets",75.00,true},{5,"Thingamajig E","Misc",120.00,false}}
)
in
Table.MinN(Products, "Price", 3)ProductID | ProductName | Category | Price | InStock | |
|---|---|---|---|---|---|
| 1 | 3 | Widget C | Widgets | 15 | FALSE |
| 2 | 1 | Widget A | Widgets | 25 | TRUE |
| 3 | 2 | Gadget B | Gadgets | 50 | TRUE |
Example 2: All orders with unit price below 30 (using a condition)
let
Sales = #table(
{"OrderID", "CustomerName", "Product", "UnitPrice"},
{{1,"Alice","Widget A",25.00},{3,"Charlie","Widget C",15.00},
{2,"Bob","Gadget B",50.00},{4,"Alice","Gadget D",75.00}}
)
in
Table.MinN(Sales, "UnitPrice", each [UnitPrice] < 30)OrderID | CustomerName | Product | UnitPrice | |
|---|---|---|---|---|
| 1 | 3 | Charlie | Widget C | 15 |
| 2 | 1 | Alice | Widget A | 25 |
Example 3: Identify the 2 lowest-paid employees
let
Employees = #table(
type table [EmployeeID = text, FullName = text, Department = text, Salary = number],
{{"E001","alice smith","Sales",55000},{"E002","BOB JONES","Engineering",95000},
{"E006","frank lee","Marketing",52000},{"E003","Charlie Brown","Marketing",72000}}
)
in
Table.MinN(Employees, "Salary", 2)EmployeeID | FullName | Department | Salary | |
|---|---|---|---|---|
| 1 | E006 | frank lee | Marketing | 52,000 |
| 2 | E001 | alice smith | Sales | 55,000 |