# AVERAGEIF formula with 2 sets of criteria

✭✭✭

Hi! I was able to use the following formula to pull data based on 1 set of criteria.

=AVERAGEIF({Range 1}, MONTH(@cell) = 7, {Range 2})

So, if range 1 includes data for the month of July, return the average of that data set in range 2.

However, now I want to further segment by type of data. But my formula is not working. What should I change?

=AVERAGEIF({Range 1}, MONTH(@cell) = 7, {Range 3}, "Google", {Range 2})

I'm trying to get the average of data that is in the month of July AND is identified as Google in range 3, then return the average of that data set in range 2.

Thanks!

Cindi

• ✭✭✭✭✭✭

No, you just have the range you want to sum placed at the wrong end of the formula:

SUMIFS(range to sum, criterion_range1, criterion1, criterion_range2, ​criterion2​)

AND is kind of built into SUMIFS and COUNTIFS. by default, all conditions must be met for it to add or count.

If {Range 2} contains the values to add up:

=SUMIFS({range 2}, {Range 1}, MONTH(@cell) = 7, {Range 3}, "Google")

Regards,

Jeff Reisman

If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!

• ✭✭✭✭✭✭

AVERAGEIF only works with one range. Unfortunately, we don't have an AVERAGEIFS yet.

What you have to do is use a SUMIFS on the two ranges to add up all the values, and then divide that by a COUNTIFS on the same ranges.

Regards,

Jeff Reisman

If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!

• ✭✭✭

Thank you Jeff. It still returns "Invalid Operation." Do I need to make an "and" in there somewhere?

=SUMIFS({Range 1}, MONTH(@cell) = 7, AND {Range 3}, "Google", {Range 2})

• ✭✭✭✭✭✭

No, you just have the range you want to sum placed at the wrong end of the formula:

SUMIFS(range to sum, criterion_range1, criterion1, criterion_range2, ​criterion2​)

AND is kind of built into SUMIFS and COUNTIFS. by default, all conditions must be met for it to add or count.

If {Range 2} contains the values to add up:

=SUMIFS({range 2}, {Range 1}, MONTH(@cell) = 7, {Range 3}, "Google")

Regards,

Jeff Reisman

If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!

• ✭✭✭

Got it! Thanks so much for the explanation, Jeff.