• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

SumIf query

H.V.K

New Member
Hi all,

I am unable to figure out why Excel SumIf formula isn't working for two price indexes

In short, I am trying to sum up total revenues as per criteria. SumIf returns 0 value for criteria <150,000 and >450,000. In fact, total revenues for those are 44,091,108 and
163,654,131 respectively

upload_2016-3-12_19-32-22.png

File is attached for your reference. Please kindly help me understand,

Much appreciated,

Leo
 

Attachments

Hi ,

For the other two cases , include the equal to sign as follows :

=SUMIF($A:$A,"=<150,000",$B:$B)

=SUMIF($A:$A,"=>450,000",$B:$B)

Change your formula to :

=SUMIF($A:$A,"=" & D2,$B:$B)

and copy down.

Narayan
 
Hi Narayan,

It works perfectly! Thank you

For my learning, could you please help me explain

1, Why didn't Excel understand the formula in the two instances, but worked for the other two? -> Has it got anything to do with the position of the equal sign "="?
2, Why putting the equal sign to create criteria "="&D2 works?

Thanks a lot Narayan,

Leo
 
Hi Leo ,

I am not sure but I think it works this way :

1. The criterion in a SUMIF function is always text.

2. The criterion can take several forms ; two of them are as follows :

equality / inequality symbol concatenated with a literal ( constant )

equality / inequality symbol concatenated with a cell reference

Now , suppose your column A had merely values such as 150,000 , 300,000 , 450,000 and so on. Your SUMIF formula could now be any one of the following :

=SUMIF($A:$A,"=300,000",$B:$B)

=SUMIF($A:$A,">300,000",$B:$B)

=SUMIF($A:$A,"<300,000",$B:$B)

These 3 forms are equivalent to the following :

=SUMIF($A:$A,"=" & "300,000",$B:$B)

=SUMIF($A:$A,">" & "300,000",$B:$B)

=SUMIF($A:$A,"<" & "300,000",$B:$B)

The first form could also be shortened to :

=SUMIF($A:$A,"300,000",$B:$B)

or even

=SUMIF($A:$A,300000,$B:$B)

since the SUMIF function treats both cases identically.

Note : When you enter the value 300000 without the quotes around it , you cannot use the comma within the 300000 ( 300,000 ) , since the comma will be taken as a parameter separator and not a thousands separator.

To summarize , if there is a constant value , all of the following are equivalent :

=SUMIF($A:$A,300000,$B:$B)

=SUMIF($A:$A,"300,000",$B:$B)

=SUMIF($A:$A,"=300000",$B:$B)

=SUMIF($A:$A,"=300,000",$B:$B)

=SUMIF($A:$A,"=" & 300000,$B:$B)

=SUMIF($A:$A,"=" & "300000",$B:$B)

=SUMIF($A:$A,"=" & "300,000",$B:$B)

Whether the literal ( constant ) is entered as a numeric value or a string is immaterial , whether the equality sign is included or not is immaterial.

--------------------------------------------------------------------------------

Once you go on to using a cell reference , then things change slightly.

Using a formula such as :

=SUMIF($A:$A,"=D2",$B:$B)

will tell Excel that you wish to see if any cell contains the text D2 ; this is certainly not what we want ; we want to use the contents of cell D2 as a value criterion.

In order to tell Excel this , the formula will have to be changed to :

=SUMIF($A:$A,"=" & D2,$B:$B)

Of course , with an equality criterion , the "=" is not required , and even the following formula will work identically :

=SUMIF($A:$A,D2,$B:$B)

When we wish to use inequalities , then the inequality symbols are mandatory.

-----------------------------------------------------------------------------------

Now to come to your specific case.

In your case , the data in column A is not just numeric values ; with the inclusion of the inequality symbols and the in between expression such as 150,000<=x<=300,000 , all of the data is text.

Thus , if we have data such as <150,000 , then a criterion in cell D2 of <150,000 will not work.

A formula such as :

=SUMIF($A:$A,D2,$B:$B)

where D2 contains the text string <150,000 , will be interpreted as :

=SUMIF($A:$A,"<150,000",$B:$B)

and since column A does not contain any numeric value less than 150,000 , the result will be 0.

To tell Excel to interpret the criterion in cell D2 as a literal text string , we will need to prefix the criterion with the equality sign as follows :

=SUMIF($A:$A,"=" & D2,$B:$B)

Now , Excel will translate this to its equivalent :

=SUMIF($A:$A,"=<150,000",$B:$B)

which will be interpreted as :

Look in column A for data which equals the text string <150,000 ; this is exactly what we want.

Narayan
 
Back
Top