Question

I have Twocolumns A, B ..I am trying to get the sum of A like below.

=SUMIFS(
       sheet1!$A:$A, 
       sheet1!$B:$B, ("AB", "BC", "CD")
       )

But this formula is not working. Please suggest me.

Was it helpful?

Solution

Try to use following formula:

=SUMPRODUCT((sheet1!$B:$B={"AB","BC","CD"})*(sheet1!$A:$A))

or alternatively you can use an array formula:

=SUM(IF(sheet1!$B:$B={"AB","BC","CD"},sheet1!$A:$A,0))

enter formula in the formula bar and press CTRL+SHIFT+ENTER to evaluate it......

OTHER TIPS

If I'm guessing your intention right, you should have:

=SUMIFS(sheet1!$A:$A,Sheet1!$B:$B,"AB")+SUMIFS(sheet1!$A:$A,Sheet1!$B:$B,"BC")+SUMIFS(sheet1!$A:$A,Sheet1!$B:$B,"CD")

Add two helper columns: in D:D you have the list of valid values. In C:C you have a formula like this (change ; to ,). In F1 you have your sum like this:

=SUMIFS($A:$A,$C:$C,FALSE)

enter image description here

Now you can add any number of valid criteria in column D:D.

You can use SUMIFS to return an array (one for each criterion) and then SUM to sum those, i.e.

=SUM(SUMIFS(sheet1!$A:$A,sheet1!$B:$B,{"AB","BC","CD"}))

This way retains the speed and efficiency of SUMIFS without needing repetition

If you have your criteria values in a range of cells you can simply reference the range, but use SUMPRODUCT to avoid "array entry"

=SUMPRODUCT(SUMIFS(sheet1!$A:$A,sheet1!$B:$B,Z2:Z4))

where Z2:Z4 contains the criteria

Note: in both of these SUMIFS does all the "heavy lifting" - SUM/SUMPRODUCT is used simply to sum the resulting array

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top