MAXIFS function

Returns the largest value from a subset of values in a list that are specified according to one or more criteria.