In Excel, we can’t simply use the default MAX function with a condition (unless you are using Microsoft Office 365).
But the thing is if want to get maximum value from a range using a specific condition you need a MAX IF formula.
So, what’s the point? You can combine MAX and IF to create a formula that can help you to get the max value from a range using specific criteria.
In short: MAXIF is an array formula that you can use to find the max value from a range using criteria. But here’s the kicker: In this post, I’m gonna share with you different ways to use the MAXIF formula.
Apply MAX IF Formula
Let’s take an example of the below data where you have month-wise, week-wise, and date-wise sales quantity.
Now from this data, you need to get the max sales quantity for a particular month. For example, “Jan” and for this, the formula will be:
And you need to enter it as an array formula by using ctrl + shift + enter.
When you enter it, it will return 200 which is the highest sales value in the month of Jan on 07-Jan-2016.
How does this Work?
To understand the working of max if you need to split it into three parts.
Please take note that you have entered it as an array formula.
First of all, you have created a logical test in the IF function to match the entire month column with the criteria. And, it has returned an array where match values are TRUE and all others are FALSE.
Second, in the IF function, you have specified the sales quantity column for the TRUE values and that’s why it has returned sales quantity only for the TRUE.
Third, the MAX function will simply return the highest number from this array which is the highest sales quantity for the month of Jan. Just like this formula hack here I’ve listed some of the others which you must read and learn.
MAX IF with Multiple Criteria
I am sure at this point you are thinking that how we can use more than one condition in max if. And that’s a smart thought. In the real world of data, there is a huge possibility that we need to use multiple criteria to get the highest value. Let’s continue with the previous example.
Let’s say, instead of the highest sales value from the month of Jan, you need to get the highest sales for week 2 of Jan. So, here you have two different conditions, the month is Jan and the week is the 2nd. And the formula will be:
And, when you enter it as an array:
How does this Work?
Here we have used nested IF to test more than one logic. One is for the month and the second is for the week. So, it returns an array where you have sales quantity only where the month is Jan, and the week is the 2nd.
And in the end, max returns the max value from that array.
MAX IF without an Array
Arrays are powerful but not everyone wants to use them. And, you have an option not to use an array in max if. So, for this, you can use the SUMPRODUCT function because it can help you to use an array without applying the actual array formula. And the formula will be:
So, when you insert this formula, you don’t need to use ctrl + shift + enter.
How does this Work?
Again, we need to split this formula into three different parts to understand it. In the first part, you have compared the month column with the criteria, and it has returned an array with TRUE where criteria matched, else FALSE.
After that, you have multiplied that array with the sales quantity column which returns an array where you have sales quantity instead of TRUE. In the end, the MAX function has returned the highest value from that array which is your highest sales quantity.
This entire formula, SUMPRODUCT has the major role to allow you to use an array without entering an actual array formula.
Getting the max value based on criteria is what we often need to do. And using this technique of max if the formula you can do it with no effort.
All the methods which you have learned above have different applications according to the situation. I hope this formula tip will help you to get better at Excel. But now, tell me one thing.
Which one do you really like, an array or without an array?
Please share your views with me in the comment section. I’d love to hear from you, and please, don’t forget to share this post with your friends, I am sure they will appreciate it.