List.Mode

Updated on

List.Mode is a Power Query M function that returns the item that appears most frequently in a list. The function returns the last item if multiple items appear with the same maximum frequency or throws an exception if the list is empty.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

List.Mode(
   list as list,
   optional equationCriteria as any,
) as any
ArgumentAttributeDescription
listThe list of values to extract the most frequent value from.
equationCriteriaoptionalUses Comparer Functions to determine how values are equated during operations. Options include Comparer.Ordinal for exact case-sensitive matching, Comparer.OrdinalIgnoreCase for case-insensitive matching, and Comparer.FromCulture for culture-specific comparisons.

Description

Returns the item that appears most frequently in the list, list. If the list is empty an exception is thrown. If multiple items appear with the same maximum frequency, the last one is chosen. An optional comparisonCriteria value, equationCriteria, can be specified to control equality testing.

Examples

Find the item that appears most frequently in the list {"A", 1, 2, 3, 3, 4, 5}.

// Output: 3
List.Mode( {"A", 1, 2, 3, 3, 4, 5} )

Find the item that appears most frequently in the list {"A", 1, 2, 3, 3, 4, 5, 5}.

// Output: 5
List.Mode( {"A", 1, 2, 3, 3, 4, 5, 5} )

Learn more about List.Mode in the following articles:

Other functions related to List.Mode are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/list-mode