Quick, clean, and to the point

Conditional mode with criteria

Excel formula: Conditional mode with criteria
Generic formula 

To calculate a conditional mode with one or more criteria you can use an array formula based on the IF and MODE functions. In the example shown, the formula in F5 is:


where "group" is the named range B5:B14, and "data" is the named range C5:C14.

Note: this is an array formula and must be entered with control + shift + enter.


The MODE function has no built-in way to apply criteria. Given a range, it will return the most frequently occurring number in that range.

To apply criteria, we use the IF function inside MODE to filter values in a range. In this example, the IF function filters values by group with an expression like this:


This compares each value in the named range "group" against the value in E5, which is "A". Because the logical test is applied to an array with multiple values, the result is an array of TRUE FALSE values:


where each TRUE corresponds to a row where the group is "A". This array becomes a filter. For each TRUE, IF returns the corresponding value in the named range "data". FALSE values remain unchanged. The final result of IF is this array:


Notice only values in group A have survived, group B values are now FALSE. This array is returned to the MODE function, which automatically ignores FALSE values and returns the most frequently occurring number, which is 3.

Note: when IF is used this way to filter values with an array operation, the formula must be entered with control + shift + enter.

Additional criteria

To apply more than one criteria, you can nest another IF inside the first IF:

Dave Bruns

Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.

Download 100+ Important Excel Functions

Get over 100 Excel Functions you should know in one handy PDF.