Excel Conditional SUMPRODUCT

Excel Video Tutorial & Transcription

Discover how to utilize the versatile SUMPRODUCT function in Excel to efficiently calculate total revenue, extract subsets of data, and determine weighted averages. These crucial skills are covered in detail in our NYC Excel classes, or in online sessions for those based elsewhere.

Key Insights

  • The SUMPRODUCT function in Excel allows you to calculate total revenue from sales and unit price data in just a single cell, eliminating the need for multiple functions or calculations.
  • Using the 'conditional SUMPRODUCT' method, you can extract a subset of data from a table, such as the total revenue for a specific state in a sales data table.
  • The SUMPRODUCT function can also be utilized for weighted average calculations, which are useful in various contexts, such as determining student scores.
  • By incorporating the 'conditional SUMPRODUCT' method into your weighted average calculation, you can focus on a specific subset of data, such as the average score for students who have graduated.
  • The 'Evaluate Formula' tool in Excel provides a behind-the-scenes look at the workings of functions like SUMPRODUCT, aiding in understanding the applied calculations.
  • Noble Desktop's Excel classes extensively cover these essential Excel functions, available both in NYC and online for remote learners.

How Conditional SUMPRODUCT Works

  1. Build Boolean Arrays

    Use comparisons like (range1 = 'X') that produce TRUE/FALSE arrays.

  2. Multiply Conditions

    TRUE×1=1, FALSE×1=0. Multiplying conditions creates an AND filter.

  3. Multiply by Values

    Multiply the filter array by the values you want to sum.

  4. Wrap in SUMPRODUCT

    SUMPRODUCT sums the resulting array — your conditional total.

The SUMPRODUCT Function and other essential Excel functions are covered extensively in our NYC Excel classes. For those outside New York, find and compare the best Excel classes near you or online Excel classes.

SUMPRODUCT Review

So let's do a quick review of SUMPRODUCT. This is a topic we cover in Level 1. If we look at this table here, we have states that have a certain number of sales for products that have a specific unit price. Unit prices are all the same in this table. Now, I would like to get the total revenue for all the states, so I can start that by typing in equal, then I'm going to select the sales, multiply that by the unit price and press ENTER.

So I have the total sales for New York, which is $212.50. I'm not going to need to retype that formula. I can simply use autofill to come up with the answers or the results for the rest, the total revenue for California, Texas, Nevada and Texas, and then finally, I'll go to the bottom and come up with the total. If I go over to the formulas tab, I can click AutoSum, press ENTER. I have $1,012.50.

So to come up with that answer, I needed to move over to another column, come up with four different functions, calculations, and then come up with a total. I can do that all in one cell using SUMPRODUCT. All I need to do is type equal, SUMP. At this point, I can press TAB, and then I'm going to select the two columns that I want to multiply with each other.

Excel Bootcamp: Live & Hands-on, In NYC or Online, Learn From Experts, Free Retake, Small Class Sizes,  1-on-1 Bonus Training. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

I'll start with sales. Then I'll enter a comma, and then I'll select the unit price. All I have to do now, after putting in a closed parenthesis, is press ENTER. And when I press ENTER, I will have the total.

Conditional SUMPRODUCT

Now what I would like to do is find the total just for Texas. This is where we're going to use conditional SUMPRODUCT to pull a subset of the information from the table. So I'm going to head over to the cell where I'm going to get the total for Texas, and I'm going to start to write the SUMPRODUCT function.

At this point, you're going to do exactly what you did in the last exercise. So equal, SUMP, tab. I'm going to select all the sales. Enter a comma and then select all the unit price. Enter a comma, and this is where things are different.

I'm going to enter a double negative. Then within the open parenthesis, I'm going to select the entire state column and add an equal sign and say that I'm looking for, in that column, "TX" in double-quotes, close parenthesis, and then a final closing parenthesis to close off the SUMPRODUCT function. I'll press ENTER. I get 350. Supposedly, the total just for Texas is 350.

Let me check to see if that is accurate. All I need to do is delete everything else that is in Texas. Let me just take a look, and there we go, 350. So conditional SUMPRODUCT was able to correctly find the total for Texas.

Now, if we want to figure out what's going on, what I'm going to do is go over to Evaluate Formula. This is one of the tools we can use to figure out what's going on behind the scenes in a function like this.

So what I'm going to do is click Evaluate. When I click Evaluate, I see a little bit more information about the numbers and the values for the SUMPRODUCT function. I see the individual sales and unit prices, and I also see false, false, true, false. So that's something you'll see at the end of another very popular function in Excel, VLOOKUP.

At the end of VLOOKUP, you'll indicate whether or not you want an exact match or an approximate match, and you'll use either false or true, but you could also use another value, zero or one. And that will determine whether or not you want an exact match or an approximate match. False is zero and true is one.

So I'm going to step out of this. And let's actually go to the Insert Function dialog box, which is located right next to the formula bar. I'll click on the Effects button. And here's what we're seeing is going on behind the scenes. When I add the double negative, I'm actually turning all the trues and falses to zeros and ones, which is their other alias. When I'm multiplying values across the board, I'm either multiplying them with zero or one. So any values that are false for Texas get multiplied by zero and cancel out those values. But any state that matches TX in that column results in a one. Therefore, I'm multiplying 75 times 2.5 times 1, and I keep the value of 75 times 2.5.

So I'll click cancel to get out of this dialog box. That's one way you can use conditional SUMPRODUCT.

Weighted Average

You can also use it to come up with a weighted average. We have scores and numbers of students and whether they graduated or not. So let's find out the weighted average.

Now the function formula that you have for this calculation is listed over to the right. That's going to be equal to SUMPRODUCT, and then we're going to select all the scores, comma, total number of students. I'm going to close that off and then divide that by the sum of the students. That will give me a weighted average for the entire student body. That's 77.30 and a lot of extra decimals. I'll go over to the home tab and decrease the decimals.

OK, so now I want to be able to come up with the conditional weighted average. I only want the weighted average for students who graduated. So that's going to be equal to SUMPRODUCT. But again, it's going to start the same. I'm going to select all the scores, comma, select all the students, and then I'm going to enter a comma and enter a double negative.

In the open parenthesis, I'm going to select the criteria range, which is the graduating column. And I'm looking for values that are equal to, in double-quotes, "Y." The first closing parenthesis closes off the red parenthesis that selects the graduating column, and then I'll use one more closing parentheses to close off SUMPRODUCT.

Now this all needs to get divided, whatever the result here is, needs to get divided by only the number of students who graduated. So I'll divide that by SUMIFS. This is a function we went over in Level 2. We're going to use it here to get a count only for the students who graduated.

So SUMIFS. First, what am I going to sum? I'm going to sum the number of students. I'm going to enter a comma, and then I need to enter a criteria range. Criteria range is "Graduating." Then I'm going to enter a comma, and then I'm going to enter the criteria. The criteria needs to be "Y." This is different from what we did in the SUMPRODUCT function. This is what you do in SUMIFS to identify the criteria for the criteria range. And then I'll press ENTER, and I get 85.00.

So that is the conditional weighted average for students who graduated, and it would make sense that that would be the conditional weighted average since the overall student body has their weighted averages dragged down by the students who didn't graduate, who got lower scores. So of course, the score is going to be lower than if you just focus on the students who graduated who have higher scores.

Recap

So that is conditional weighted averages and also how you can use conditional SUMPRODUCT to come up with it. We also took a look at how you can get a subset of data using conditional SUMPRODUCT as it relates to sales for numerous states.

Video Transcription:

Full Video Transcript

Introduction to Conditional SUMPRODUCT

Conditional SUMPRODUCT uses SUMPRODUCT with conditions to exclude data that does not meet a certain criteria. You can use conditional SUMPRODUCT to extract the subset of the information that you want and exclude everything else.

Let's do a quick review of SUMPRODUCT. This is a topic we cover in level one. If we look at this table here, we have states that have a certain number of sales for products that have a specific unit price. The unit prices are all the same in this table.

Calculating Total Revenue the Traditional Way

Now I would like to get the total revenue for all the states. I can start that by typing in equals, then I'm going to select the sales, multiply that by the unit price, and press enter. So I have the total sales of New York which is $212.50. I'm not going to need to retype that formula. I can simply use autofill to come up with the answers or the results for the rest—the total revenue for California, Texas, Nevada, and then finally I'll go to the bottom and come up with the total.

If I go over to the Formulas tab, I can click AutoSum, press enter, and I have $1,012.50. So in order to come up with that answer, I needed to move over to another column, come up with four different function calculations, and then come up with a total.

Using SUMPRODUCT for Efficient Calculations

I can do that all in one cell using SUMPRODUCT. All I need to do is type equals S-U-M-P. At this point I can press Tab, and then I'm going to select the two columns that I want to multiply with each other. I'll start with sales, then I'll enter a comma, and then I'll select the unit price. All I have to do now after putting in a closed parenthesis is press enter, and when I press enter I will have the total.

Adding Conditions to Filter Data

Now what I would like to do is find the total just for Texas. This is where we're going to use conditional SUMPRODUCT to pull a subset of the information from the table. I'm going to head over to the cell where I'm going to get the total for Texas and I'm going to start to write the SUMPRODUCT function.

At this point you're going to do exactly what you did in the last exercise. Equals SUM P Tab, I'm going to select all the sales, enter a comma, and then select all the unit price. Enter a comma, and this is where things are different. I'm going to enter a double negative, then within the open parenthesis I'm going to select the entire state column and add an equal sign and say that I'm looking for in that column "TX" in double quotes. Close parentheses and then a final closing parenthesis to close off the SUMPRODUCT function.

I'll press enter. I get 350. Supposedly the total just for Texas is 350. Let me check to see if that is correct. All I need to do is delete everything else that isn't Texas, and let me just take a look. There we go, 350. So conditional SUMPRODUCT was able to correctly find the total for Texas.

Understanding the Double Negative Logic

Now if we want to figure out what's going on, what I'm going to do is go over to Evaluate Formula. This is one of the tools we can use to figure out what's going on behind the scenes in a function like this. I click evaluate and I see a little bit more information about the numbers and the values for the SUMPRODUCT function. I see the individual sales and unit prices, and I also see false, false, true, false.

That's something you'll see at the end of another very popular function in Excel, VLOOKUP. At the end of VLOOKUP you'll indicate whether or not you want an exact match or an approximate match, and you'll use either false or true. But you could also use another value, 0 or 1, and that will determine whether or not you want an exact match or an approximate match. False is zero and true is one.

I'm going to step out of this and let's actually go to the Insert Function dialog box, which is located right next to the formula bar. I'll click on the fx button. Here's what we're seeing going on behind the scenes: when I add the double negative, I'm actually turning all the trues and falses to zeros and ones, which is their other alias.

So when I'm multiplying values across the board, I'm either multiplying them with zero or one. Any values that are false for Texas get multiplied by zero and cancel out those values. But any state that matches TX in that column results in a one. Therefore I'm doing 75 times 2.5 times 1, and I keep the value of 75 times 2.5. I'll click cancel to get out of this dialog box.

Calculating Weighted Averages

That's one way you can use conditional SUMPRODUCT. You can also use it to come up with a weighted average. We have scores and numbers of students and whether they graduated or not. Let's find out the weighted average.

The function and formula that you have for this calculation is listed over to the right. That's going to be equal to SUMPRODUCT, and then we're going to select all the scores, comma, total number of students. I'm going to close that off and then divide that by the sum of the students. That will give me a weighted average for the entire student body. That's 77.30 and a lot of extra decimals. I'll go over to the Home tab and decrease the decimals.

Conditional Weighted Average for Graduates

Now I want to be able to come up with the conditional weighted average. I only want the weighted average for students who graduated. That's going to be equals SUMPRODUCT. Again, it's going to start the same. I'm going to select all the scores, comma, select all the students, and then I'm going to enter a comma, enter a double negative. In the open parentheses, I'm going to select the criteria range which is the graduating column, and I'm looking for values that are equal to, in double quotes, "Y". The first closing parenthesis closes off the parentheses that selects the graduating column, and then I'll use one more closing to close off SUMPRODUCT.

Now this all needs to get divided. Whatever the result here is needs to get divided by only the number of students who graduated. I'll divide that by SUMIFS. This is a function we went over in level two. We're going to use it here to get a count only for the students who graduated.

SUMIFS first—what am I going to sum? I'm going to sum the number of students. I'm going to enter a comma, and then I need to enter a criteria range. The criteria range is graduating. Then I'm going to enter a comma and enter the criteria. The criteria needs to be "Y". This is different than what we did in the SUMPRODUCT function. This is what you do in SUMIFS to identify the criteria for the criteria range. Then I'll press enter and I get 85.00.

Summary and Key Takeaways

So that is the conditional weighted average for students who graduated. It would make sense that this would be the conditional weighted average since the overall student body has their weighted averages dragged down by the students who didn't graduate, who got lower scores. Of course the score is going to be lower than if you just focus on the students who graduated, who have higher scores.

So that is conditional weighted averages and also how you can use conditional SUMPRODUCT to come up with it. We also took a look at how you can get a subset of data using conditional SUMPRODUCT as it relates to sales for numerous states.

Learn more in these courses

How to Learn Excel

Master Excel with Hands-on Training. Excel is the Leading Spreadsheet Application Used by over 750 Million People Worldwide.

Yelp Facebook LinkedIn YouTube Twitter Instagram