ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trying to summarize same values (https://www.excelbanter.com/excel-programming/447652-trying-summarize-same-values.html)

riktubrs

Trying to summarize same values
 
Hey,

I have this, for example:

Column A:
X
Y
Z
X

Column B:
1
2
3
4

I want to be able to summarize all values in Column B which Column A=X or Column A=Y. The result should be 7 (1+2+4).

I did this:

SUM(IF(COUNTIF(A:A,"X"),VLOOOKUP("X",A:B,2,),"0"), IF(COUNTIF(A:A,"Y"),VLOOOKUP("Y",A:B,2,),"0"))

For some reason, it returns 3. It doesn't adds the second value of X for some reason.

Any ideas why?

Thanks!

Howard

Trying to summarize same values
 
On Wednesday, November 14, 2012 4:24:51 PM UTC-8, riktubrs wrote:
Hey,



I have this, for example:



Column A:

X

Y

Z

X



Column B:

1

2

3

4



I want to be able to summarize all values in Column B which Column A=X

or Column A=Y. The result should be 7 (1+2+4).



I did this:



SUM(IF(COUNTIF(A:A,"X"),VLOOOKUP("X",A:B,2,),"0"), IF(COUNTIF(A:A,"Y"),VLOOOKUP("Y",A:B,2,),"0"))



For some reason, it returns 3. It doesn't adds the second value of X for

some reason.



Any ideas why?



Thanks!









--

riktubrs


Hi riktubrs,

Try this:

=SUMIF(A1:A4,"X",B1:B4)+SUMIF(A1:A4,"Y",B1:B4)

HTH
Regards,
Howard


All times are GMT +1. The time now is 04:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com