Skip to main content

How to use the AND and SUMIF Functions in Excel


 - Two more useful Conditional Functions are AND( ) and SUMIF( ). We'll stay with the students exam results to examine these two functions. If you haven't yet downloaded the spreadsheet we're using for these lessons, click below. (If you've been following along, you can use this new spreadsheet: it has the CountIF already done!)


The AND Function

Here's the scenario. The government have decided to take a closer look at school averages. If 4 or more students in a subject get a score of 70 or above, then the school gets a cash bonus for that subject. There are 8 subjects, so 8 cash bonuses are up for grabs.
First, we'll use the AND function to work out if 4 or more students have scores of 70 or above.
The AND( ) function checks a list of arguments and determines whether they are true or false. If all the arguments are true then the function gives you an answer of TRUE. If one or more of the arguments are false, then the function gives you an answer of FALSE.
To give you an easy example. You can check whether two plus two does indeed equal 4. Click inside an empty cell of your spreadsheet, then click inside the formula bar. Enter this:
=AND(2 + 2 = 4)
When you press the Return key, Excel gives you the answer TRUE. Now change it to 2 + 3 = 4 and see what happens.
So Excel checked the argument to see whether it was true or false. That's all it will check for, an either or answer. You can have up to 30 arguments between the AND brackets. You could have this, for example:
= AND(2 + 2 = 41 + 2 = 4)
There's two arguments to check there. Excel will check the first one and return an answer of TRUE. When it checks the second one it will return an answer of False. The answer to the whole function will then be FALSE. (It's false because all conditions have to be true before the overall answer is TRUE.)
Our AND function is going to be quite simple. We're going to check the B column, the Number of students who have Below Average scores.
  • So click inside C15
  • Click inside the formula bar
  • Enter the following formula :
= AND(B15 >= 4)
  • Press the return key on your keyboard
  • Excel will enter True in this cell (B15 is the cell where we had a score of 4)
  • Use Auto Fill to calculate the rest of the AND functions
  • Your spreadsheet should look something like the one below:
All we're saying in our function is "IF the cell B15 is greater than or equal to 4 THEN put True in cell C15, else put False". Remember: the government pays out if 4 or more students get above a score of 70 for a lesson
Now that we have some True/False values for our C column, we can check all these True/False values. We want to add up all the cash values associated with our TRUE cells. However, we haven't got any cash values yet, so let's do that now. Enter the same cash values as in the image below:
The values are just potential values. A school only gets them if 4 or more students gain a score of 70 or above in that subject. So there's a potential ten thousand for Maths, five thousand for English, 8 thousand for Science, etc.
OK, we have 2 cells with TRUE in them. There is a different cash value associated with each subject. We have a TRUE for English, so the school will receive 5 thousand pounds for this. The school can expect 10, 000 for Maths. But we need a way to add all the cash values associated with the TRUE values. We can use SUMIF for this.

SumIF

SUMIF is a little bit more complicated than AND, but not much more. This function adds up things depending on the criteria you give it. (Add up the cost of all apples, for example.) The function expects certain arguments. These are:
SUMIF(rangecriteriasum_range)
The first argument, range, is the cell or cells you want to check. For us, this would be the TRUE and FALSE values in the D column. The second argument, criteria, is what you want to check for. In our case this is the value TRUE. The third argument, sum_range, are the cells to add up. The figures we want to add up are all in the E column.
  • So click in an empty cell (E24 is ideal for us)
  • Click inside the formula bar
  • Enter the following SUMIF function:
=SUMIF(C15:C22, TRUE, E15:E22)
  • Press the return key on your keyboard
  • Excel adds up only the value associated with TRUE
If everything went well, then you should have a figure of 11 thousand for your SUMIF function. Your spreadsheet might look like the one below:
The SUMIF function
So our SUMIF function said "Check the cells C15 to C22. If a cell has TRUE in it, make a note of the ammount in the E cell next to it. When you've finished, add them all up."
The SUMIF might be a bit tricky to master, but it can come in quite handy, and it's worth making the effort to understand exactly how it works.
In any case, that concludes are little journey into conditional logic. Hope you're not too disappointed to be leaving the subject behind!

In the next section of the Excel course, we'll take a look at Tables, Scenarios and Goal Seek.

Comments

Popular posts from this blog

PRATYUSHA HOME

Hi interesting readers, Prathysha NGO, Chennai. Bala gurukul orphange, chennai. Pratyusha support, Hyderbad. Krr oldage home, Vizag. Disa foundation.......................................................... so on..................... Join hands with us for a good cause. Thank you all. Contact  us on our  whatsapp no:  8939374254    for the more details. You can pay through Paytm scanner. for each donor we will give an online PDF book as a gift. Thank you Pratyusha Home
Javascript Tutorials for the Beginner - Welcome to the Home and Learn course for Javascript. Although it is aimed at complete beginners to the subject we do assume that you have some knowledge of HTML and a little CSS. You don't have to be an expert, though. Just the basics will do. (If you're not sure about the HTML then see our Web Design course.) You don't need to buy any software for this Javascript course - you probably already have everything you need to get started.   > Section One: Getting Started 1. Software needed 2. Our Javascript Templates 3. A little word about debugging Home Page > Section Two: The Browser 1. A First Script 2. Javascript Tag Placement 3. The Browser Object Model 4. Browser Window Methods 5. The Document Object Model > Section Three: Javascript Programming Basics 1. Javascript Variables 2. Math Operators 3. Operator Precedence 4. IF Statements 5. IF ... Else 6. Comparison Operators 7...
Sorting Images in Windows 7  -In the previous section, you learned how to add information to an image. In this section, you'll se what you can do with all this information. This comes under the topic of Sorting. First, though, change your View slider from  Tiles  to  Details : When you arrange the window to Details view, your screen should look like this one: We now have a list of images with the Name, Date, Tags, Size and Ratings showing. These headings can all be used to sort your images. Click on the Ratings, for example, and you'll see a dropdown box: You can choose to display only images with 1, 2, 3, 4 or 5 stars. All you need to do is to check each box. The ones not checked will then be hidden: Here, we're choosing to display only 1 and 2 star images, perhaps with a view to deleting them. (To delete an image, right-click. From the menu that appears, select  Delete . Or choose  Rename  to change the name of the image....