OpenBI Docs Buy

Table.MinN

The bottom rows by a column or by a value worked out per row: a number of them, or as many as meet a condition.

Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Table.MinN(table as table, comparisonCriteria as any, countOrCondition as any) as table
ParameterTypeDescription
tabletableThe rows to rank.
comparisonCriteriaanyA column name; a pair {name, Order.Descending}; a list of names or pairs; or a function of a row that gives the value to compare.
countOrConditionanyHow many rows to keep, or a condition: rows are taken from the lowest while it holds.

Returns

table. The rows from the lowest up, with all of the table's columns.

Remarks

  • With a condition, the rows are ordered lowest first and taken until the first one that fails it.

Examples

The two weakest shops

let
    Shops = #table({"Shop", "Sales"}, {{"Oslo", 120}, {"Bergen", 340}, {"Trondheim", 90}, {"Stavanger", 210}})
in
    Table.MinN(Shops, "Sales", 2)
ShopSales
Trondheim90
Oslo120

Products running low

let
    Stock = #table({"Product", "Stock"}, {{"Chair", 3}, {"Desk", 0}, {"Lamp", 12}, {"Sofa", 1}})
in
    Table.MinN(Stock, "Stock", each [Stock] < 5)
ProductStock
Desk0
Sofa1
Chair3

Lowest first: the lamp, with 12, is where the condition first fails.

Table.MaxN, Table.Min, Table.FirstN, Table.Sort.

Last updated · OpenBI Studio 0.3.79