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
| Parameter | Type | Description |
|---|---|---|
table | table | The rows to rank. |
comparisonCriteria | any | A 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. |
countOrCondition | any | How 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)
| Shop | Sales |
|---|---|
| Trondheim | 90 |
| Oslo | 120 |
Products running low
let
Stock = #table({"Product", "Stock"}, {{"Chair", 3}, {"Desk", 0}, {"Lamp", 12}, {"Sofa", 1}})
in
Table.MinN(Stock, "Stock", each [Stock] < 5)
| Product | Stock |
|---|---|
| Desk | 0 |
| Sofa | 1 |
| Chair | 3 |
Lowest first: the lamp, with 12, is where the condition first fails.