Finding a more efficient way of using SUM PRODUCT and COUNTIF

若如初见. 提交于 2020-07-07 11:55:28

问题


I currently have this formula which works but it takes a few seconds for excel to catch up, and I was wondering if anyone knew about a more efficient way of handling this. Aside for it taking a few seconds to process when I drag the formula down excel doesn't update the new cells and eventually crashes the entire file.

=SUMPRODUCT(((Paste!$B$2:$B$12000=A2))/COUNTIFS(Paste!$B$2:$B$12000,Paste!$B$2:$B$12000&"",Paste!$C$2:$C$12000,Paste!$C$2:$C$12000&""))

Sample Data:


回答1:


Let's imagine the data layed out in front of us as you present:



1) Formulas Without DA-functionality:

You could apply this method:

In F3:

=SUM(--(FREQUENCY(IF(A$3:A$9=E3,MATCH(B$3:B$9,B$3:B$9,0)),ROW(B$3:B$9)-2)>0))

Enter through CtrlShiftEnter


2) With DA-functionality

You could apply this method:

In F3:

=COUNTA(UNIQUE(FILTER(B3:B9,A3:A9=A2)))

Adapt any of the above to fit your ranges and needs, but do remember array formula may just way heavily on calculation.


3) Pivot Table:

If you want to avoid formulas alltogether, simply select all your data e.g. A2:B9 and follow these steps:

  • Click tab Insert from the ribbon and choose PivotTable
  • Choose where to insert the resulting table and check "Add this data to the Data Model"
  • Use "Process" as column, and "Test_ID" as values.
  • Go to "Value Field Settings" and summarize values by "Distinct Count"
  • Confirm and enjoy the resulting table:



来源:https://stackoverflow.com/questions/62202292/finding-a-more-efficient-way-of-using-sum-product-and-countif

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!