New Contributor

# Help with a function in Excel

I'm trying to make a formula that will average a range of cells, but only if those cells are labeled by a specific month ("Jan"). I've tried the if function :

=IF(B8:BB8="Jan"),AVERAGE(B9:BB9),"-"

But I keep getting the "#VALUE!” error in the cell where the answer would be.
6 Replies

# Re: Help with a function in Excel

If you have the newest version of Excel, you can do this easily with the new Dynamic Array function called FILTER.

Here's the formula: =AVERAGE(FILTER(B9:BB9,B8:BB8="Jan"))

# Re: Help with a function in Excel

If the FILTER function doesn't work with your version of Excel, try this:

=SUMIF(B8:BB8,"Jan",B9:BB9)/COUNTIF(B8:BB8,"Jan")

# Re: Help with a function in Excel

This seemed to actually produce something! Which is a start. However if there are 5 days worth of scores in January ("Jan") and say you got a 60 I'd want the average to come to 60. Is there a way to make it average only filled in cells for cells containing "Jan"?

# Re: Help with a function in Excel

You wrote: This seemed to actually produce something! Which is a start.

To which I need to respond: "Which 'this' are you referring to?" I gave you two separate ways of doing what you'd asked.

You then wrote: However if there are 5 days worth of scores in January ("Jan") and say you got a 60 I'd want the average to come to 60.

To which my first response is, at least in my own example on my Mac, the first solution I gave you (using FILTER) does produce that 60 if there's only one entry.

After which I'd continue with wondering, "if there are five days worth of scores in January and you got a 60" isn't the average actually 12 (else why are we saying there are "five days worth of scores").   If what you're saying instead is that "Jan" gets mentioned five times, but there's in fact only one day in Jan with a score, that's something different.

See, the problem here is that the English language is delightfully ambiguous--and we may or may not understand what one another are saying even though each of us thinks of himself as crystal clear. Writers love to play with words precisely because of the possibility of multiple meanings, and usually, in person, we're able to understand one another from the bigger context, from nuances in body language, etc.

Computers, however, are pretty literal.

Anyway, if that first response doesn't work on your computer (FILTER is only available in the newest Excels), I'd suggest playing around more with the COUNT functions for the divisor to calculate your average only based on numbers of numbers under "Jan"

# Re: Help with a function in Excel

AVERAGEIFS() is another option

# Re: Help with a function in Excel

If what you're saying instead is that "Jan" gets mentioned five times, but there's in fact only one day in Jan with a score, that's something different.

This is exactly what I'm looking for. at the moment. January has 5 weeks, but only 2 are filled. so essentially although there are five weeks in the month it should add the two scores and divide by two. As I add scores, it should divide 3 scores by 3 and so on. I don't have the FILTER function. so I am still having some issues.