Sum up unique values in column per criteria in other column

杀马特。学长 韩版系。学妹 提交于 2021-01-28 02:25:19

问题


   |       A                 B           
---|----------------------------------------- 
1  |    Total              1.900
---|-----------------------------------------
2  |    Product_A           700        
3  |    Product_A           700  
---|-----------------------------------------      
4  |    Product_B           300        
---|-----------------------------------------
5  |    Product_C           200      
6  |    Product_C           200      
---|------------------------------------------
7  |    Product_D           700         
8  |    Product_D           700      
9  |    Prodcut_D           700  
10 |

In Cell B1 I want to sum the unique values in Column B per product in Column A.

B1 = 700 + 300 + 200 + 700

Currently, in Cell B1 I use the formular from this question which is =SUM(UNIQUE(B2:B9)).
However, with this formula I get 1.200 as result because it does not include the 700 from Product_D.


How do I have to modify the formula so it sums up the values unique per product?


回答1:


As you have UNIQUE() function then you can use it with index and sum like-

=SUM(INDEX(UNIQUE(A2:B9),,2))




回答2:


Try SUMPRODUCT instead.

=SUMPRODUCT(B2:B9/COUNTIF(A2:A9,A2:A9))

It will get you the sum of values in B for unique values in A.

Note: this is assuming,the values in B2:B9 are all numeric. If not you will get a #VALUE error



来源:https://stackoverflow.com/questions/64348101/sum-up-unique-values-in-column-per-criteria-in-other-column

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