英文:
Is there a way to combine Excel AVERAGEIF with AGGREGATE?
问题
我有一个包含阶段(阶段1,阶段2等)和每个阶段的百分比值的电子表格列。每个阶段都有多个百分比值,我想计算每个阶段的平均百分比。
我之前使用AVERAGEIF来计算每个阶段的平均百分比:
AVERAGEIF(Table1[PHASE], "Phase 1", Table1[PERCENTAGE])
等等。
这个方法很好用。然而,如果任何百分比值是“N/A”或者错误,我不希望它们影响计算结果。
我了解到AGGREGATE可以忽略错误,但它只适用于AVERAGE,而不适用于AVERAGEIF。我也了解到AVERAGEIF(A1:A5, ">=0")
以及用于多个错误值的AVERAGEIFS,但这不允许我比较PHASE列。
欢迎任何建议。
英文:
I have a spreadsheet with a col of phases (Phase 1, Phase 2, etc.) and col of percentage values for each phase. There are multiple of each phase and I want to calculate the average % for each phase.
I was using AVERAGEIF to calculate the average percentage for each Phase:
AVERAGEIF(Table1[PHASE], "Phase 1", Table1[PERCENTAGE])
, etc.
That works fine. However, if any percentage values are N/A
or errors, I don't want this to skew the calculations.
I read about AGGREGATE that ignores errors, but that only works with AVERAGE, not AVERAGEIF.
I also read about AVERAGEIF(A1:A5,">=0")
and AVERAGEIFS for multiple error values, but this doesn't allow me to compare the PHASE col.
Any suggestions welcome.
答案1
得分: 2
对于Microsoft 365,请尝试以下公式...
=AVERAGE(FILTER(Table1[PERCENTAGE],(Table1[PHASE]="Phase 1")*(ISNUMBER(Table1[PERCENTAGE]))))
对于早期版本,请尝试以下需要使用CONTROL+SHIFT+ENTER确认的公式...
=AVERAGE(IF(Table1[PHASE]="Phase 1",IF(ISNUMBER(Table1[PERCENTAGE]),Table1[PERCENTAGE])))
然而,您提到包含百分比值的列包含错误值,以及文本值"N/A"。如果错误值是相同类型的,假设是#DIV/0!,您可以简单地使用以下公式...
=AVERAGEIFS(Table1[PERCENTAGE],Table1[PERCENTAGE],"<>#DIV/0!",Table1[PHASE],"Phase 1")
相应地更改要测试的错误值。
英文:
For Microsoft 365, try the following formula...
=AVERAGE(FILTER(Table1[PERCENTAGE],(Table1[PHASE]="Phase 1")*(ISNUMBER(Table1[PERCENTAGE]))))
For earlier versions, try the following formula that needs to be confirmed with CONTROL+SHIFT+ENTER...
=AVERAGE(IF(Table1[PHASE]="Phase 1",IF(ISNUMBER(Table1[PERCENTAGE]),Table1[PERCENTAGE])))
However, you say that the column containing the percentage values contain error values, in addition to the text value "N/A". If the error values are the same type, let's say #DIV/0!, you can simply use the following formula instead...
=AVERAGEIFS(Table1[PERCENTAGE],Table1[PERCENTAGE],"<>#DIV/0!",Table1[PHASE],"Phase 1")
Change the error value for which to test accordingly.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论