计算 excel 中数据的绝对值的平均值,忽略空白 (" ") 单元格

Averaging the absolute values of data in excel, ignoring blank (" ") cells

我正在 excel 中构建一个预测方法比较工具。我必须使用 excel 来完成这个特定的任务。我需要比较不同类型的误差(MAE-平均绝对误差、RMSE-均方根误差等)以显示哪种方法做得最好。

我将错误(残差)整理如下:

Column 1   Column 2
  -0.5       1.2
  1.5        -1
   ""        ""          #  <==== here is what is causing the issue
   0.2       1.5

问题是有时数据集没有完全填充,我内置了 'if' 语句 return ""(我可以从 'if' 语句)如果在某个日期没有 activity。 这不会导致计算平均误差或 RMSE 或预测出现问题。

我尝试了以下公式(对数组公式使用 ctrl+shift+enter):

=average(abs(DATA-RANGE))
=sum(abs(DATA-RANGE))/count(DATA-RANGE) # I calculated the count in another cell

如果不是包含“”的单元格,我相信这些会起作用(根据在另一个地方找到的解决方案)

有什么想法吗?电子表格已经很大,我想在不创建新列的情况下执行此操作(即创建一个新的 abs(DATA) 列来计算平均值)。

我也想在没有任何 VBA/macros 的情况下制作它 - 它需要让那些除了简单的 excel 公式之外什么都不知道的人可以访问。

谢谢!

编辑 1: Here I have tried both Scott and Tom's method with my data. Both work! I even tried removing some of the formulas that provide the "" (so that true blank spaces were there), and it did not return #VALUE in either method. The formula in the edit box is what is being used to calculate the errors. Much obliged!

试试下面的数组公式:

=AVERAGE(IF(A2:B5<>"",ABS(A2:B5)))

作为数组公式,必须用 Ctrl-Shift-Enter 确认。如果操作正确 Excel 会自动将 {} 放在公式周围。

适用于空单元格和包含 ="" 的单元格的非 CSE 公式是

=SUMPRODUCT(ABS(N(+A2:B5))*(A2:B5<>""))/COUNT(A2:B5)

或者因为空单元格或其中有引号的单元格不计入总和,

 =SUMPRODUCT(ABS(N(+A2:B5)))/COUNT(A2:B5)

and also