Skip to main content

List.MaxN

Επιστρέφει τις μέγιστες τιμές στη λίστα. Πρέπει να καθοριστεί ο αριθμός των τιμών που θα επιστραφούν ή μια συνθήκη φίλτρου.

Syntax

List.MaxN(
list as list,
countOrCondition as any,
optional comparisonCriteria as any,
optional includeNulls as logical
) as list

Remarks

Returns the maximum value(s) in the specified list. After the rows are sorted, optional parameters can be specified to further filter the result.

  • list: The list of values.
  • countOrCondition: Specifies the number of values to return or a filter condition. If a number is specified, a list of up to countOrCondition items in descending order is returned. If a condition is specified, the returned list includes all items that meet the condition.
  • comparisonCriteria: (Optional) A function that's used to transform the values before they're compared. If this parameter is null, then the values are compared without any transformation.
  • includeNulls: (Optional) Indicates whether null values in the list should be included in determining the maximum item. The default value is true.

Examples

Example #1

Βρείτε τις 5 κορυφαίες τιμές στην καθορισμένη λίστα.

List.MaxN({3, 4, 5, -1, 7, 8, 2}, 5)

Result:

{8, 7, 5, 4, 3}

Example #2

Βρείτε τις λέξεις με περισσότερους από 3 χαρακτήρες.

List.MaxN(
{"boy", "dog", "pony", "cat", "rabbit", "bat"},
each Text.Length(_) > 3
)

Result:

{"rabbit", "pony"}

Example #3

Βρείτε τις τρεις πιο πρόσφατες ημερομηνίες από μια λίστα με γερμανικές ημερομηνίες.

let
Source = {"12.02.2024", "15.05.2025", "10.10.2021", "16.01.2025", "30.12.2022"},
MaxDate = List.MaxN(Source, 3, each Date.FromText(_, [Culture = "de-DE"]))
in
MaxDate

Result:

{
"15.05.2025",
"16.01.2025",
"12.02.2024"
}

Category

List.Ordering