AVERAGE when some cells contain text

slam

Well-known Member
Joined
Sep 16, 2002
Messages
921
Office Version
  1. 365
  2. 2019
I’m having a hard time dealing with an AVERAGE. If B3 is blank, I need “” displayed, otherwise I need it to calculate the average of E3:W3. The problem I’m having is that there is sometimes text in E3:W3. I still want it to include those cells in the average and assume they are 0. How do I go about this? Currently I'm just getting an error.
 
Sorry, I'm back. I just showed this to my buddy, and he thinks it should function slightly differently. Nothing wrong with your formula. He just wants my requirements to change a little.

Apparently DNS should not be counted in the average, but DNF should be considered 0. Also, there's a third potential piece of text which is DSQ, and that should function the same way as DNF - treated as 0.
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Sorry, I'm back. I just showed this to my buddy, and he thinks it should function slightly differently. Nothing wrong with your formula. He just wants my requirements to change a little.

Apparently DNS should not be counted in the average, but DNF should be considered 0. Also, there's a third potential piece of text which is DSQ, and that should function the same way as DNF - treated as 0.

Back to Hotpepper's suggesstion.... Replace DNS with DSQ in the formula.
 
Upvote 0
or an "array formula" to do the same

=IF(B3="","",AVERAGE(IF((E3:W3="DNF")+(E3:W3="DSQ"),0,E3:W3)))

confirmed with CTRL+SHIFT+ENTER
 
Upvote 0
One final little tweak then I promise I'll stop changing things? :)

So I'm currently using this:
=IF(B3="","",SUM(E3:W3)/MAX(1,COUNT(E3:W3)+SUM(COUNTIF(E3:W3,{"DSQ","DNF"}))))

I think if there's only DNS or "" in E3:W3, the result should be ""
 
Upvote 0
=if(or(countif(e3:w3,"dns")=19,b3=""),"",sum(e3:w3)/max(1,count(e3:w3)+sum(countif(e3:w3,{"dsq","dnf"}))))
 
Upvote 0
=if(or(countif(e3:w3,"dns")=19,b3=""),"",sum(e3:w3)/max(1,count(e3:w3)+sum(countif(e3:w3,{"dsq","dnf"}))))

That's still giving me a result of 0 for rows that only have DNS or "". Looking for a result of "" for those.
 
Upvote 0
Try

=IF(B3="","",IF(COUNT(E3:W3)+SUM(COUNTIF(E3:W3,{"DSQ","DNF"})),SUM(E3:W3)/(COUNT(E3:W3)+SUM(COUNTIF(E3:W3,{"DSQ","DNF"}))),""))
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top