Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
929 views
in Technique[技术] by (71.8m points)

excel - Tolerant average (ignore #NA, etc.)

I want to calculate the average over a range (B1:B12 or C1:C12 in the figure), excluding:

  1. Cells not being numeric, including Empty strings, Blank cells with no contents, #NA, text, etc. (B1+B8:B12 or C1+C8:C12 here).
  2. Cells for which corresponding cells in a range (A1:A12 here) have values outside an interval ([7,35] here). This would further exclude B2:B3 or C2:C3. At this point, cells in column A may contain numbers or have no contents.

I think it is not possible to use any built-in AVERAGE-like function. Then, I tried calculating the sum, the count, and divide. I can calculate the count (F2 and F7), but not the sum (F3), when I have #N/A in the range, e.g.

How can I do this?

Notes:

  1. Column G shows the formulas in column F.
  2. I cannot filter and use SUBTOTAL.
  3. B8:C8 contain Blank cells with no contents, B9:C9 contain Empty strings.
  4. I am looking for (non-user defined) formulas, i.e., non-VBA.

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

From https://stackoverflow.com/a/30242599/2103990:

Providing you are using Excel 2010 and above the AGGREGATE function can be optioned to ignore all errors.

=AGGREGATE(1, 6, A1:A5)

????????AGGREGATE excluding errors


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...