Calculate conditional mode with criteria in Excel

To calculate a conditional mode with one or more criteria you can use an array formula based on the IF and MODE functions.

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




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.

How this formula works

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

Also See:   How to compare two text strings in Excel

To apply criteria, we use the IF function to test each data value in “group” to see if it matches the value in E5 (“A”):


Because the logical test is based on an array containing multiple values (the named range “group”), the result is an array of TRUE FALSE results:


where each TRUE represents a row where the group is “A”. This array acts as 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 data values in group A have “survived”; group B values are now FALSE. This array goes into the MODE function, which returns the most frequently occurring number in group A, which is 3.

Also See:   Calculate number of hours between two times in Excel

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:


Leave a Reply

Your email address will not be published. Required fields are marked *