Explanation
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.
This array becomes a filter.
For each TRUE, IF returns the corresponding value in the named range “data”.
FALSE values remain unchanged.
For example, =MODE(1,2,4,4,5,5,5,6) returns 5.