Table.Min returns the row (or value) with the lowest value in a column you choose, so it answers questions like "which order shipped first", "what is the earliest date in this list" or "which product has the lowest price". It is a native Power Query M function, so there is nothing to install: you need a query with a table in it, and a column you want to compare. The syntax is Table.Min(table as table, comparisonCriteria as any, optional default as any) as any. If you want the smallest number or date rather than the whole row, wrap it in a field name: Table.Min(MyTable, "DateColumn")[DateColumn].
What You'll Need
- A Power BI Desktop, Excel Power Query or Dataflows environment where the Power Query Editor opens normally (in Excel, Data > Get Data > Launch Power Query Editor).
- A query whose output is a table, not a single value, and which contains at least one numeric, date, time, datetime, logical or text column to compare. Labels and settings can differ slightly by version, app and region.
- Column names written exactly as they appear in the table header, including spaces and capitalisation, wrapped in double quotes.
- An optional second column name if you want to break ties, and an optional default value to return instead of a blank or an error for an empty table.
Step-by-Step
- Load your data into a query. Open the Power Query Editor, get your source (for example Data > Get Data > From File, or a table in the current workbook), and confirm the preview shows the rows you expect. Promoted headers are important: if the first row is still row 1 rather than column names, use Home > Use First Row as Headers before going further.
- Check the column's data type. Select the column header and confirm the icon shows a whole number, decimal number, date or datetime as appropriate. Table.Min compares values, and text that looks like a date ("2024-03-01" stored as text) will be compared alphabetically, which usually gives a different answer. Change the type with the icon in the header or with Transform > Data Type.
- Open the Advanced Editor. On the Home tab, choose Advanced Editor. Find the step that produces the table you want to query, and note its name (typically
#"Changed Type"or similar) — you will reference it in the next step. Note the quoting style: spaces and special characters mean step names need#"...". - Add a step that calls Table.Min. At the bottom of the script, before the closing
invalue, add something likeEarliest Order = Table.Min(#"Changed Type", "OrderDate"). Replace the step name and column name with your own. If you only want the date or number, add[OrderDate]straight after the closing parenthesis so you get a scalar value instead of a one-row record. - Point the query output at the new step. Change the final
inline to reference the new step, e.g.in Earliest Order, then choose Done. The preview should now show a single record (in the editor, as a row of field/value pairs) or a single value. - Test it with a known value. Sort the column the other way temporarily in a duplicate query, or eyeball the smallest value in the column, and confirm the result matches. This catches the most common problem — text or mixed types — before it reaches a report.
- Break ties deliberately. When two rows share the lowest value, Table.Min returns the first matching row in the table's current order, which is not guaranteed to be meaningful. To control it, add a tie-breaker column — the comparison criteria can be a list of column names, for example
Table.Min(MyTable, {"OrderDate", "OrderID"})— or sort the table on a stable second column first with Table.Sort. - Load or use the result. Close and Load the query if you want the value on a worksheet or report page, or reference the query from another query (for example to filter a fact table down to the earliest shipment) using its query name.
Common Mistakes
Forgetting the field name. Table.Min(MyTable, "Date") returns a record containing the whole row. Without at the end, expressions like Date.Year(...) fail because they receive a record rather than a date.
Comparing text as text. A column left on type Any or Text gives alphabetical minimums, so "10" sorts before "9" and "Apr" before "Jan". Always set the type first.
Using the wrong step name. Reference the actual step that holds the table. Naming an earlier step compares stale data, and misspelling a step with spaces breaks the whole query with a syntax error.
Ignoring errors in the column. A single error value in the column can break the comparison. Use Replace Errors or Remove Errors on the column before calling Table.Min.
Expecting an empty table to return blank. Table.Min on an empty table raises an error unless you supply the optional third argument, for example Table.Min(MyTable, "Date", null). Use the default argument whenever your source can legitimately have zero rows.
Confusing min with first. Table.Min and Table.First are not the same. Table.First depends on row order and changes whenever the source reorders; Table.Min depends on values and is stable.
Tips
- Use
Table.Min(MyTable, "Price")[Price]when you want a number to feed into a calculation, andTable.Min(MyTable, "Price")[ProductName]when you want to label it (the same record holds every field of that row). - For the inverse, use Table.Max with identical arguments. Both accept a single column name or a list of columns for multi-column comparison.
- Give the step a readable name ("Earliest Ship") so colleagues can follow the script in the Advanced Editor and in the Query Settings pane.
- Add a comment line above the step with
//explaining what it does; comments survive edits in the Advanced Editor and are harmless when the query runs. - If you need the minimum plus other aggregates, do the aggregation in one Table.Group step instead of calling Table.Min several times against the same table.
- Keep the comparison column's type set close to the source step. Re-typing in several places is the main reason a min result changes unexpectedly after a refresh.
Troubleshooting
"We cannot convert a value of type Record": you are passing a record where a table is expected, or referencing the result of a previous Table.Min. Make sure the first argument is a step that still returns a table.
The answer is a record or a table icon, not a value: add the field name in square brackets after the call, or expand the record with the column header menu.
Wrong minimum after a refresh: check the column type in the applied steps and look for a later step that sorts or re-types. Sort direction alone does not change the result, but a type change from date to text does.
An error appears only on some rows: filter or replace errors in the comparison column. Text mixed into a numeric column is the usual culprit, and Table.Min has no tolerance for it.
Empty-table error: supply the default argument, or guard the step with if Table.IsEmpty(MyTable) then null else Table.Min(...).
The whole query will not validate: open the Advanced Editor and check commas, quotes and the #"..." escaping around step names. If you want to start over, delete the custom step and add it again; nothing else in the query is lost because the steps are stored independently.
Frequently Asked Questions
Does Table.Min need the whole table or can I pass a column?
It needs a table as the first argument and a column name (or list of names) as the second. To get only the value, add [ColumnName] after the call.
What is the difference between Table.Min and List.Min?
List.Min works on a list of values and returns a value. Table.Min works on a table and returns the entire lowest row, which is why it can fetch related fields from the same record.
How do I get the row with the lowest value in one column but the highest in another?
Pass a list of column names as the comparison criteria. The first column decides, and later columns only break ties, so order the list to match your priority.
Why does my date column give the wrong earliest date?
It is almost always stored as text, so it compares alphabetically. Set the column to Date or Date/Time and refresh.
What happens if two rows share the minimum?
You get the first one in the table's current order. Add a tie-breaking column or sort the table first if the specific row matters.
Can Table.Min return blank when there are no rows?
Only if you pass a default as the third argument. Otherwise an empty table produces an error.