Table.MinN Function in Power Query

The Table.MinN function returns the smallest N rows in the given table. After the rows are sorted, the countOrCondition parameter must be specified to further filter the result.

Syntax

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

Note: • If a number is specified, a list of up to countOrCondition items in ascending order is returned.
• If a condition is specified, a list of items that initially meet the condition is returned. Once an item fails the condition, no further items are considered.

Example: Find the smallest three records.

Power Query M

let
  MyTable = Table.FromRecords(
    {
      [CustomerID = 1, Name = "Ashish", Marks = 568], 
      [CustomerID = 2, Name = "Katrina", Marks = 855], 
      [CustomerID = 3, Name = "Alia", Marks = 380], 
      [CustomerID = 4, Name = "Vicky", Marks = 458], 
      [CustomerID = 5, Name = "Mohini", Marks = 278], 
      [CustomerID = 6, Name = "Meenakshi", Marks = 289], 
      [CustomerID = 7, Name = "Esha", Marks = 875], 
      [CustomerID = 8, Name = "Anjali", Marks = 380]
    }
  ), 
  #"Return Output" = Table.MinN(MyTable, "Marks", 3)
in
  #"Return Output"   

The output of the above code is shown below:

Table.MinN in Power Query