Sum up unique values in column per criteria in other column (if columns are filtered)

一曲冷凌霜 提交于 2021-02-11 13:22:46

问题


With reference to this quesion in Cell B1 I use the formula =SUM(INDEX(UNIQUE(A2:B9),,2)) in order to only sumup the unique values per product.

All this works perfectly.


Now, I set a filter in Column A and exclude for example Product_A and Product_C from the list:

As you can see the 1.900 in Cell B1 remains. However, I only want to apply the formula in Cell B1 to the filtered data which means that - in this case - the value in Cell B1 should be 1.000.


Normally, I could achieve this with a SUBTOTAL formula but I do not have any clue how I can combine the UNIQUE and INDEX function with the SUBTOTAL.


回答1:


Bit of a stretch to be honest:

=SUM(INDEX(UNIQUE(IF(SUBTOTAL(2,OFFSET(A2:A9,ROW(A2:A9)-ROW(A2),1,1)),A2:B9)),,2))

You could always just avoid the volatile function and use:

=SUM(INDEX(UNIQUE(FILTER(A2:B9,(A2:A9<>"Product_A")*(A2:A9<>"Product_C"))),0,2))


来源:https://stackoverflow.com/questions/65490849/sum-up-unique-values-in-column-per-criteria-in-other-column-if-columns-are-filt

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