We can use an array formula that is based on IF and MODE function to calculate a conditional mode with one or more criteria. This post looks at how we can use these two functions to calculate conditional mode with criteria.
Figure 1: How to calculate conditional mode with criteria
General syntax of the formula
How the formula works
- It is important to note that the MODE function has got no built-in way to apply any criteria.
- This means that the function will return the most occurring number in any range supplied to it.
- We need to use the IF function to apply a given criteria, which tests the data value in the group to see if it matches the supplied criteria.
- The logical test is based on an array containing multiple values, thus the result should also be an array of TRUE FALSE.
- Here, each TRUE will represent a row with “B” as the group, as in our above example. The IF function will then return the corresponding value for each TRUE in the array. FALSE values will not be changed.
- In our example above, we shall have an array of results that looks more like the one below;
- The array will then be taken to the MODE function so that we can get the most frequently occurring value in the group. In our example, this value is C which appears 5 times.
- It is important to note that the formula is an array formula, thus needs to be entered in an array format.
Instant Connection to an Expert through our Excelchat Service
Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.