Power Query List.Min Function: How to Use It
In this article
The List.Min function in Power Query returns the smallest value from a list of numbers or text (alphabetically). To use it, you need a list—typically created from a column in a table or manually defined—and it works in both Power Query Editor in Excel or Power BI. No special setup is required beyond having data accessible in Power Query.
What You'll Need
- A list of values: either a column from a table (e.g., sales figures, dates, names), or a manually entered list like
{1, 5, -3, 10} - Power Query Editor open in Excel (Data > Get Data > From Other Sources > From Microsoft Query) or Power BI (Get Data > transform data)
- Basic familiarity with adding custom columns or using the Advanced Editor
Step-by-Step
- Load your data into Power Query: In Excel, go to the Data tab > select From Table/Range (if your data is in a table) or From Workbook/Text/CSV. In Power BI, go to Home > Get Data and choose your source. Once loaded, click Transform Data to open the Power Query Editor.
- Locate the column you want to analyze: In the Power Query Editor pane, find the column containing the values you want to find the minimum of (e.g., a numeric column like "Sales" or "Price", or a text column like "ProductName" if comparing alphabetically).
- Create a new custom column using List.Min: Click on the Add Column tab > select Custom Column. In the dialog box, name your column (e.g., "MinValue"). In the Custom column formula box, enter
List.Min(TableName[ColumnName]). ReplaceTableNamewith the actual name of your query (e.g., "SalesData") andColumnNamewith the column name (e.g., "Price"). For example:List.Min(SalesData[Price]). Click OK. - Or use List.Min in the Advanced Editor for more control : Right-click your query in the Queries pane > Advanced Editor. To return a single minimum value across an entire column, replace any existing code with something like: . This returns a scalar value (a single number or text item). Press Done to apply.
- Handle blank or null values: By default,
List.Minignores nulls. If your list contains only nulls, it returns null. To avoid errors, ensure your source list is filtered: useList.Select(TableName[Column], each _ <> null)before passing toList.Min. For example:List.Min(List.Select(SalesData[Price], each _ <> null)). - Close & Load: Once your column or query is set up, click Close & Load to load the result back into Excel or Power BI as a table or scalar value (depending on your query type).
Common Mistakes
- Using the wrong table name: If you reference
Table1[Column]but your query is named "SalesData", Power Query throws a "Name not recognized" error. Always double-check the query name in the Queries pane. - Passing a table instead of a list:
List.Minrequires a list, not a table. WritingList.Min(TableName)(without column selection) fails. Always use the bracket notation:TableName[Column]. - Ignoring data types: If a column is set to "Any" or "Text" but contains mixed types (e.g., numbers and text),
List.Minmay return unexpected results or errors. Convert the column to the correct type first (right-click column > Change Type). - Assuming it works row-by-row:
List.Minevaluates the entire list at once. It does not compute a minimum per row. For per-row minima across multiple columns, useList.Min({[Col1], [Col2], [Col3]})in a custom column. - Not handling empty lists: If the list is empty (e.g., due to filtering),
List.Minreturns an error. Wrap it intry ... otherwise ...or useif List.IsEmpty(...) then null else List.Min(...).
Tips
- Combine with List.Buffer for large lists: If performance is slow, use
List.Buffer(List.Min(TableName[Column]))to cache the list in memory before computing the minimum. - Use it with List.Distinct to avoid duplicates skewing results:
List.Min(List.Distinct(TableName[Column]))ensures only unique values are considered. - For dates, it works naturally: Power Query treats dates as numbers internally.
List.Min(DateTable[OrderDate])returns the earliest date. - Text comparison is case-sensitive : "apple" and "Apple" are treated differently. To make it case-insensitive, normalize first: .
- Test with a small sample: Before applying to a full dataset, test your formula on a filtered query containing just 5–10 rows to verify correctness.
Troubleshooting
If List.Min doesn’t work as expected, follow these checks:
- Check for syntax errors: Open the Advanced Editor and look for red underlines. Common issues include missing brackets, misspelled column names, or incorrect table references. Ensure parentheses and square brackets match:
List.Min(Source[Column]), notList.Min(Source[Column). - Verify data types: Right-click the column header > Data Type. If it’s "Any" or "Text" but should be "Number", change it. A text column with "100", "20", "5" will sort alphabetically ("100" < "20"), giving the wrong minimum.
- Test for nulls or blanks: Add a custom column with
= [ColumnName]and sort descending. If you see many blanks or errors, filter them out using the filter dropdown orList.Select. - Use Evaluate in the formula bar: In the formula bar above the query steps, type
List.Min(TableName[Column])and press Enter. If it returns a value, the issue is likely in how you applied it to the table. If it errors, the list itself is problematic. - Simplify the expression: Temporarily replace the table reference with a hardcoded list:
List.Min({1,2,3})should return 1. If that works, the issue is with your data source or column reference. - Restart Power Query or Excel: Occasionally, the editor caches errors. Close and reopen Excel, then reload the query.
Frequently Asked Questions
Can List.Min handle text values?
Yes. For text, it returns the alphabetically first value (e.g., List.Min({"Zebra", "apple", "Apple"}) returns "Apple" due to case sensitivity). It does not consider length or meaning.
Does List.Min ignore nulls automatically?
Yes. Null values are skipped during comparison. If all values are null, it returns null. If you need to treat nulls as zeros or another value, replace them first: List.Transform(TableName[Column], each if _ = null then 0 else _).
Why does List.Min give a different result than Excel's MIN function?
Power Query uses strict data types. If Excel treats a column as text (e.g., "10" vs. 10), MIN returns "10" as smallest. In Power Query, if the column is text, "100" is smaller than "20". Convert to Number type in Power Query to match Excel’s numeric behavior.
Can I use List.Min with a list from multiple columns?
Yes. In a custom column, combine columns into a list first: List.Min({[SalesJan], [SalesFeb], [SalesMar]}). This computes the minimum across those three columns for each row.
What happens if the list is empty?
List.Min({}) throws an error: "We cannot apply operator min to types List and List." Use if List.IsEmpty(myList) then null else List.Min(myList) to return null instead.
Does List.Min work with dates?
Yes. Dates are stored as serial numbers, so List.Min({#date(2023,12,1), #date(2024,1,1)}) returns #date(2023,12,1). Ensure the column is set to Date type for correct interpretation.