The Table.Max function in Power Query finds the row with the largest value in a column and gives you that whole row. So instead of just the top number, you also get who, what, or when it belongs to.
In this article, I’ll show you how to use it with practical examples, from finding the top row in a table to getting the top item in each group and handling ties, empty tables, and numbers stored as text.
Follow along with the example file
Table.Max Function Examples.xlsx
Table.Max Function Syntax
= Table.Max(table as table, comparisonCriteria as any, optional default as any) as any
- table – the table you want to search. This is usually the previous step, such as
Source. - comparisonCriteria – what decides the largest row. Most of the time, this is a column name in double quotes, like
"Amount". It can also be a function such aseach [Qty]*[Unit Price], or a list of columns when you need a tie-breaker. - default (optional) – the value to return if the table has no rows. If you leave it out, an empty table gives you null.
What it returns – the whole row with the largest value, as a record. If the table is empty, it returns the default value (or null).
The Table.Max function works in Power Query in Excel for Microsoft 365, 2024, 2021, 2019, 2016, and Excel for Mac (Microsoft 365), as well as in Power BI.
When to Use the Table.Max Function
Use this function when you need to:
- Find the row with the highest value, not just the value itself
- Get one detail from the top row, like the name of the top seller
- Find the most recent entry in a log by its date
- Find the largest row based on a calculation, without adding a column
- Get the top item or the latest row in each group with Table.Group
- Return a fallback value when a filtered table has no rows
Example 1: Find the Row With the Highest Value
Let’s start with the basic use, finding the top row in a table.
Below is a list of donations to a fundraiser, and I want to find the donation with the highest amount, along with who gave it.

To follow along, select any cell in the table and go to Data > From Table/Range to open it in the Power Query Editor. If Power Query adds a Changed Type step, use #"Changed Type" in place of Source in the formulas below.
Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.Max(Source,"Amount")
Result: a record with Donor Judith Wallace, City Austin, and Amount 1200

Here, Table.Max looks at the Amount column, finds the largest value (1200), and returns the whole row it sits in. That’s why you see the donor and the city too, not just the amount.
The result is a record, which is one row with its column names. Power Query shows it as a two-column list, with the field names on the left and the values on the right.
The column name has to match exactly, including its capitalization. If you type a column that isn’t in the table, like "Amt", you get the error “The specified sort criteria is invalid.”
If you want the smallest row instead, the Table.Min function works the same way. And if you want the top few rows as a table (say the top 3 donations), use the Table.MaxN function.
Example 2: Get One Value From the Top Row
Most of the time, you only need one detail from the top row, not the whole row.
Below is a list of hotel rooms with their nightly rates, and I want the name of the most expensive room.

Load this table into Power Query the same way as in Example 1, then add a new step (by clicking on the fx icon) and use this formula:
= Table.Max(Source,"Nightly Rate")[Room]
Result: Ocean Suite
![Table.Max with [Room] returns Ocean Suite](https://trumpexcel.com/wp-content/uploads/2026/11/tmax-04-ex2-result.png)
Here, Table.Max returns the row with the highest nightly rate (349), and [Room] picks the Room field from that row. So you get the room name as a single text value.
This is the difference between Table.Max and the List.Max function. List.Max(Source[Nightly Rate]) would give you 349, but it can’t tell you which room charges it.
Example 3: Find the Most Recent Entry
Table.Max isn’t only for amounts. On a date column, the largest value is the latest date.
Below is a service log for machines in a factory, and I want to find the most recent service entry, with the machine and the technician who worked on it.

This query needs a type change before Table.Max, so it’s easiest to paste the whole query in the Advanced Editor. Go to Data > Get Data > From Other Sources > Blank Query, then open the Advanced Editor (Home > Advanced Editor).
The table in the example file is named ServiceLog. If your table has a different name, change it in the Source line of this code:
let
Source = Excel.CurrentWorkbook(){[Name="ServiceLog"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Service Date",type date}}),
#"Latest Service" = Table.Max(#"Changed Type","Service Date")
in
#"Latest Service"
Result: a record with Machine Conveyor B, Technician Craig, and Service Date 11/12/2026

Here, the Changed Type step makes Service Date a date column. Then Table.Max finds the latest date (11/12/2026) and returns that whole row.
The log isn’t sorted by date, and it doesn’t need to be. Table.Max checks every row, so the latest entry is found wherever it sits in the table.
The date shows as 11/12/2026 because my computer uses US date settings. On a computer with UK settings, the same date shows as 12/11/2026, but the value is the same.
Example 4: Find the Largest Row Based on a Calculation
Sometimes the value you want to compare isn’t in a column. You have to calculate it first.
Below is a list of order lines with the quantity and unit price of each item, and I want to find the order line with the largest total value (quantity times price).

Load this table into Power Query the same way as in Example 1, then add a new step (by clicking on the fx icon) and use this formula:
= Table.Max(Source,each [Qty]*[Unit Price])
Result: a record with Order ID SO-1042, Item Office Chair, Qty 3, and Unit Price 189

Here, instead of a column name, I’ve given Table.Max a function. It works out Qty times Unit Price for each row and returns the row where that total is the largest.
The six totals are 288, 567, 375, 498, 360, and 516, so the Office Chair line (3 x 189 = 567) wins.
Note that the winner is neither the row with the biggest Qty (Notebook) nor the one with the highest Unit Price (Monitor). Table.Max compares the two multiplied together, and that’s largest for the Office Chair.
The result shows the row as it is in the table, so the 567 total isn’t part of it. If you need the total in the output too, add it as a column first with the Table.AddColumn function, then use Table.Max on that column.
Follow along with the example file
Table.Max Function Examples.xlsx
Example 5: Get the Top Item in Each Group
This next one comes up a lot, and it’s where Table.Max is most useful.
Below is a list of copies sold for three book titles at three branches of a bookstore, and I want the best-selling title in each branch.

Load this table into Power Query the same way as in Example 1, then add a new step (by clicking on the fx icon) and use this formula:
= Table.Group(Source,{"Branch"},{{"Best Seller",each Table.Max(_,"Copies Sold")[Title],type text}})
Result: a table with each branch and its best seller: Downtown – Salt and Cedar, Riverside – Northbound, Airport – The Quiet Orchard

Here, the Table.Group function splits the table into one small table per branch. For each of those, _ stands for that branch’s rows, so Table.Max(_,"Copies Sold") finds the top row in that branch, and [Title] takes the title from it.
The type text at the end tells Power Query that the new column holds text.
If you use the Group By dialog with the Max operation instead, you only get the highest number of copies for each branch. Table.Max is what gets you the title that sold those copies.
Also, the rows don’t need to be sorted by branch first, because Table.Group collects each branch’s rows wherever they are.
Example 6: Get the Latest Row in Each Group
Here’s a variation of the previous example, where you need more than one value from each top row.
Below is a price log where a new row is added every time a product’s price changes, and I want the latest price of each product along with the date it took effect.

This query has more than one step, so it goes in the Advanced Editor. Create a new blank query the same way as in Example 3, open the Advanced Editor, and use this code (the price log table is named PriceLog):
let
Source = Excel.CurrentWorkbook(){[Name="PriceLog"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Effective Date",type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type",{"Product"},{{"Latest",each Table.Max(_,"Effective Date")}}),
#"Expanded Latest" = Table.ExpandRecordColumn(#"Grouped Rows","Latest",{"Effective Date","Price"})
in
#"Expanded Latest"
Result: a table with the latest row for each product: Olive Oil 1L (11/3/2026, 12.99), Basmati Rice 5kg (10/1/2026, 15.49), and Ground Coffee 500g (10/20/2026, 10.49)

Here, the Changed Type step makes Effective Date a date column, so Table.Max compares real dates.
Then Table.Group creates one group per product, and Table.Max(_,"Effective Date") returns the row with the latest date in each group. This time there’s no [Title]-style field at the end, so the Latest column holds the whole row as a record.
The last step uses the Table.ExpandRecordColumn function to turn that record into regular Effective Date and Price columns. You end up with one row per product, showing its current price.
Example 7: Break a Tie Between Rows
Now let’s look at what happens when two rows share the top value.
Below is the result of a quiz, with each contestant’s score and the time they took in seconds, and I want to find the winner. Two contestants scored 20, and the one who finished faster should win.

Load this table into Power Query the same way as in Example 1, then add a new step (by clicking on the fx icon) and use this formula:
= Table.Max(Source,"Score")
Result: a record with Contestant Tiffany, Score 20, and Seconds 395

Here, Andrea and Tiffany both scored 20, and Table.Max returned Tiffany, the later of the two rows. But Andrea finished faster (371 seconds), so she should be the winner.
In my tests, Table.Max always returned the last of the tied rows. Microsoft doesn’t document what happens in a tie, though, so don’t build a query that depends on it.
To decide the winner yourself, give Table.Max a second column to compare when the first one ties. Change the formula to this:
= Table.Max(Source,{{"Score",Order.Ascending},{"Seconds",Order.Descending}})
Result: a record with Contestant Andrea, Score 20, and Seconds 371

Here, Table.Max compares Score first, and only looks at Seconds for the rows that tie on Score. With Order.Ascending, the higher value wins, just like before.
Order.Descending flips that for Seconds, so the lower time wins. That’s why Andrea’s 371 seconds beats Tiffany’s 395.
Example 8: Return a Default Value When There Are No Rows
This one helps when you filter a table first and there’s a chance nothing is left.
Below is a list of refund requests with their status, and I want the largest refund that’s still pending. Right now, none of them are pending.

Load this table into Power Query the same way as in Example 1, then add a new step (by clicking on the fx icon) and use this formula:
= Table.Max(Table.SelectRows(Source,each [Status]="Pending"),"Amount","No pending refunds")
Result: No pending refunds

Here, the Table.SelectRows function keeps only the pending requests, which leaves an empty table. Table.Max has no row to return, so it returns the third argument, “No pending refunds”.
Without that third argument, the same formula returns null, which is easy to miss in a report.
When there are pending requests, the formula returns the pending request with the largest amount, as a record. So this query returns a record on some days and text on others.
That matters if a later step reads a field from the result, like [Amount], because a field can’t be read from text and the step fails.
In that case, replace “No pending refunds” in the formula with [Amount=0], which is a record with one field, Amount, set to 0. Then, when nothing is pending, a later [Amount] step gets 0 instead of an error.
A table that has rows but only blank (null) amounts isn’t empty, though. In that case, Table.Max still returns one of those rows, not the default value.
Example 9: Fix the Wrong Result From Numbers Stored as Text
This last one is a problem you can easily miss, because the formula doesn’t give you an error.
Below is a list of freight invoices where the Amount values are stored as text (that’s why they’re left-aligned), and I want the invoice with the largest amount.

Load this table into Power Query the same way as in Example 1. If Power Query adds a Changed Type step, delete it for now, since it may already change Amount to numbers.
Then add a new step (by clicking on the fx icon) and use this formula:
= Table.Max(Source,"Amount")
Result: a record with Invoice INV-301, Carrier Swift Haul, and Amount 980

Here, Table.Max returned the 980 invoice, even though INV-303 is 2275. Because the amounts are text, they’re compared like words, one character at a time, and “9” comes after “2” and “1”.
The same thing happens with other text in a number column. A single text value like “N/A” in a column of numbers beats all of them, because Power Query ranks text above numbers when it compares them.
To fix it, change the Amount column to a number type before Table.Max. Create a new blank query the same way as in Example 3, open the Advanced Editor, and use this code (the invoice table is named FreightInvoices):
let
Source = Excel.CurrentWorkbook(){[Name="FreightInvoices"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Amount",type number}}),
#"Largest Invoice" = Table.Max(#"Changed Type","Amount")
in
#"Largest Invoice"
Result: a record with Invoice INV-303, Carrier BlueRoute, and Amount 2275

Here, the Changed Type step turns the Amount text into real numbers, so Table.Max compares them by value and returns the 2275 invoice. Whenever Table.Max returns a row that looks wrong, check the column type first.
Other Excel Articles You May Also Like:
- List.Min function
- List.First – Use List.First in Power Query M to get the first item in a list.
- Table.Sort – Use Table.Sort in Power Query M to reorder table rows alphabetically, by number, or by date.
- Table.ReverseRows – Use Table.ReverseRows in Power Query M to flip row order.
- Table.FirstN – Use Table.FirstN in Power Query M to keep the first rows of a table.
- Table.AddRankColumn – Use Table.AddRankColumn in Power Query M to rank rows.
- Table.Distinct – Use Table.Distinct in Power Query M to remove duplicate rows.
- Table.RowCount – Use Table.RowCount in Power Query M to count table rows.