Table.Max is a Power Query M function that finds the largest row in a table based on comparison criteria. The function returns the largest row, or an optional default value if the table is empty.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Table.Max(
table as table,
comparisonCriteria as any,
optional default as any,
) as any
Description
Returns the largest row in the table
, given the comparisonCriteria
. If the table is empty, the optional default
value is returned.
Examples
Find the row with the largest value in column [a] in the table ( {[a = 2, b = 4], [a = 6, b = 8]} )
.
// Output: [a = 6, b = 8]
Table.Max(
Table.FromRecords( {
[a = 2, b = 4],
[a = 6, b = 8]
} ),
"a"
)
Find the row with the largest value in column [a] in the table ( {} )
. Return -1 if empty.
// Output: -1
Table.Max( #table( {"a"}, {} ), "a", -1 )
Related articles
Learn more about Table.Max in the following articles:
- How to Group By Maximum Value using Table.Max – Power Query
Working with table objects is a key skill to learn. This article explains how you can reached into grouped data using Table.Max function in Power Query. » Read more
Related functions
Other functions related to Table.Max are:
- Table.AggregateTableColumn
- Table.First
- Table.FirstN
- Table.FirstValue
- Table.Last
- Table.LastN
- Table.MaxN
- Table.Min
- Table.MinN
- Table.SingleRow
