Table of contents
TOC
Collapse the table of content
Expand the table of content

Table.MaxN

Owen Duncan|Last Updated: 10/5/2018
|
1 Contributor

About

Returns the largest N rows from a table. After the rows are sorted, the countOrCondition parameter must be specified to further filter the result.

Table.MaxN(table as table, comparisonCriteria as any, countOrCondition as any) as table  

Arguments

ArgumentDescription
tableThe Table to check.
comparisonCriteriaLargest N rows comparison criteria.
countOrConditionAfter the rows are sorted, countOrCondition further filters the result.

The countOrCondition arument has two possible settings:

ArgumentDescription
as a numberA list of items up to countOrCondition items in ascending order is returned.
as a conditionA list of items that initially meet the condition is returned. Once an item fails the condition, no further items are considered.

Examples

Table.MaxN(Employees, "Salary", 3)   
equals  Table.FromRecords({[Name="Jeff", Level=10, Salary=200000]   
[Name="Barb", Level=8,  Salary=150000]   
[Name="Bill", Level=7,  Salary=100000]})  
Table.MaxN(Employees, "Salary", each [Level] > 7)  
  
equals  Table.FromRecords( {[Name="Jeff", Level=10, Salary=200000]   
[Name="Barb", Level=8,  Salary=150000]})  
© 2018 Microsoft