Table.MinN

Table

Returns the N rows with the lowest values according to the given comparison criteria.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

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

Parameters

NameTypeRequiredDescription
tabletableYesThe table to search.
comparisonCriteriaanyYesA column name, list of column names, or comparer function defining the sort order.
countOrConditionanyYesA number specifying how many bottom rows to return, or a condition function.

Return Value

tableA 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)
Result
ProductID
ProductName
Category
Price
InStock
13Widget CWidgets15FALSE
21Widget AWidgets25TRUE
32Gadget BGadgets50TRUE

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)
Result
OrderID
CustomerName
Product
UnitPrice
13CharlieWidget C15
21AliceWidget A25

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)
Result
EmployeeID
FullName
Department
Salary
1E006frank leeMarketing52,000
2E001alice smithSales55,000

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks