The omnipotent SUMPRODUCT for learning Excel functions!
In the previous article "The magical AGGREGATE of Excel function learning, one can actually be worth 19! 》, we learned about a powerful statistical function. Today we are going to talk about the SUMPRODUCT function. The sumproduct function can get the sum of the products of two columns of data. However, there are many things to pay attention to when using the function, especially after using logical values and arrays. Let's do it together. Check out the explanation!
1. The essence of SUMPRODUCT
The SUMPRODUCT function is really very simple. To get the sum of the products of two columns of data, we use a simple example to illustrate the basic function of the function:
The picture above is a very simple table to calculate the total price Generally, the unit price * quantity is calculated and then summed. The result is shown in D8. If you use the SUMPRODUCT function, you can directly calculate the total price using the unit price and quantity. Formula 1 is: =SUMPRODUCT(B2:B7,C2:C7), and the result is shown in D9.
In this formula, two parameters are used, namely the unit price area (B2:B7) and the quantity area (C2:C7). The function of the function is to convert the first The data in the first parameter (unit price) and the second parameter (quantity) are multiplied and then summed.
2. Reasons for most errors
Many friends often get error values when using this function, mostly because The area size selection is inconsistent. For example, in the following case, the first parameter has 7 cells and the second parameter only has 6 cells:
Use The SUMPRODUCT function must ensure that the area size of each parameter is the same, but many friends have not noticed this.
3. Another common way of writing is to change the comma into a multiplication sign (*)
For this example, there is another way of writing that is more For common use, the formula is as follows: =SUMPRODUCT(B2:B7*C2:C7)
You can see that the calculation result is the same as =SUMPRODUCT(B2:B7,C2: C7) is consistent.
The consistent results have led to a question that many friends are puzzled by: What is the difference between the two?
4. The difference between a comma and a multiplication sign (*)
Although it only changes the comma in the first formula into a multiplication sign (*), but the meaning of the formula changes. The first formula (SUMPRODUCT(B2:B7,C2:C7)) has two parameters, while the second formula (B2:B7*C2:C7) has one parameter. (To determine how many parameters there are, you need to see whether they are separated by commas.) In the first formula, the step of multiplying two areas is completed by a function. The function does two things. First, let the two areas The corresponding data are multiplied, and then the products are added. In the second formula, the multiplication of two areas is done by array calculation, and the function only does one thing, which is to add the product values.
What is the impact of the change in meaning?
Let’s look at it through an example:
In the formula above, a comma (,) is used, and there are two independent parameters. The SUMPRODUCT function first multiplies the two sets of data correspondingly. During the multiplication, it checks the data and treats non-numeric data as 0, and then adds the products. Therefore, B1 "Unit Price" and C1 "Quantity" will be treated as 0, and the formula can obtain correct results.
When we replace the comma with an *, the formula result is wrong. why? The SUMPRODUCT function is only responsible for adding the products at this time. Parameters B2:B7*C2:C7 are array multiplication operations. Because the calculation area contains text (text cannot be multiplied), there is an error value in the calculation result of this array. Select "B2:B7*C2:C7" in the formula and press F9 to view the operation results of B2:B7*C2:C7:
You can see the first ( The result of the operation (unit price * quantity) is the error value. Next, SUMPRODUCT sums the data containing error values, and the result must be an error.
5. Key points of using the multiplication sign (*) in SUMPRODUCT
The above content has two meanings:
First, using commas and using * sometimes have the same results, but the meanings are completely different. I hope everyone can understand.
Second, when using the multiplication sign (*) in the SUMPRODUCT function, you must pay attention to two points: first, there cannot be uncalculated content, such as text; second, if two or more sets of arrays are multiplied, , the data area size is the same. When using commas, you only need to ensure that the size of the data area is consistent.
6. In fact, the multiplication sign also brings greater advantages
We use A, B is replaced by SUMPRODUCT (A, B) and SUMPRODUCT (A*B). When it is a comma, A and B must both be numeric values or arrays at the same time. One cannot be a numeric value and the other is an array. When it is a multiplication sign, A and B can be both numeric values or arrays at the same time, or one can be a numeric value and the other an array. .
That is:
##comma, |
Multiplication sign* |
||
##SUMPRODUCT (C1,B1) |
√
| ##SUMPRODUCT(C1*B1) | √|
(C1:C9,D1:D9) | √SUMPRODUCT(C1:C9*D1:D9) |
√ |
|
SUMPRODUCT(C1:D9,F1:G9) |
#√ |
SUMPRODUCT(C1:D9*F1:G9) |
√ |
SUMPRODUCT(C1:C9,D1) |
× |
#SUMPRODUCT(C1:C9*D1) |
√ |
SUMPRODUCT(C1:D9,F1) |
# × |
SUMPRODUCT(C1:D9*F1) |
#√ |
Therefore, the application of the SUMPRODUCT function is expanded with the multiplication sign. What you are about to see below are applications of the SUMPRODUCT function using the multiplication sign.
7. Do you understand these SUMPRODUCT formulas?
If you understand the above content, it means that the basic usage of this function is no problem. But it is very likely that you still can’t understand many SUMPRODUCT formulas, such as this one:
This is actually a conditional counting problem, look at this one again:
This is a multi-condition summation problem, and there is this:
In this table, almost all kinds of statistical problems are You can use the SUMPRODUCT function to solve it, so I won’t give examples one by one. There may not be many friends who can understand just the three formulas listed above.
Why do I understand how to use the SUMPRODUCT function but still can’t understand these formulas, let alone use them to solve problems myself? The reason is that you don't understand these two knowledge points: logical values and arrays.
8. Learn a little about logical values and arrays
Let’s talk about logical values first. There are only two logical values, TRUE and FALSE. When we make some kind of comparison or judgment in a formula, a logical value will be generated. Take SUMPRODUCT((I2:I22="Zhang San")*1) as an example, where (I2:I22="Zhang San") ) is a judgment. Normally, we make judgments based on cells. I2 = "Zhang San" means to judge whether the content of cell I2 is "Zhang San". If so, it will get TRUE, otherwise it will get FALSE. When we use an area to judge, we will get a set of data, which is actually an array. For example, I2:I22="Zhang San" will get a set of logical values. You can use F9 to see the calculation results:
If you are interested, you can compare the salespersons one by one. And the result value, you will find that Zhang San’s corresponding values are all TRUE.
Because logical values cannot be summed directly, they must be converted into numbers. The conversion method is to perform any operation such as addition, subtraction, multiplication, or division on the logical values. In this formula, *1 has this effect. You can see the effect:
After the *1 operation, TRUE becomes 1, and FALSE becomes 0. Don't ask me why, this is how Excel stipulates it, and this is the corresponding relationship between logical values and numbers.
Okay, we first get a set of logical values, then use *1 to turn them into a set of numbers, and then sum them up to achieve the purpose of counting by condition. Do you understand the formula =SUMPRODUCT((I2:I22="Zhang San")*1) now?
Now we understand logical values and the first principle of array operations: when a group of numbers is calculated with a number, each data in the group of numbers is calculated with this number. calculate. This is how it is calculated in the formula just now.
9. No matter how complicated the SUMPRODUCT formula is, understand it all!
Let’s take a look at the second formula: =SUMPRODUCT((MONTH(F2:F22)=3)*(H2:H22="Second Branch")*( G2:G22="shirt")*J2:J22)
.
Don’t look at the length of this formula. It is actually very simple to use the knowledge we just learned to crack it. The formula still has only one parameter, but this parameter is composed of four arrays, three of which are logical values, namely (MONTH(F2:F22)=3), (H2:H22="Second Branch") and (G2:G22="shirt"). These three sets of logical values complete three judgments and correspond to three conditions: month = 3, store = second branch and name = shirt. The specific content is as shown in the picture:
It looks densely packed, but after multiplication, it becomes a bunch of 1s and 0s. The result is like this:
The product result has only two 1s, which actually corresponds to the two pieces of data about the shirts from the second branch in March. The formula at this time becomes a set of logical values (already 0 and 1) multiplied by a set of data (quantity), and then the function completes the sum.
In this example, you need to pay attention to the second principle of array calculation: when multiple (including two) arrays are calculated (four arrays in this example), the data at the corresponding position in the array is calculated. It is required that the number of data contained in the array is the same.
So far we have understood the two principles of array calculation. Here is a simple example to illustrate:
An array (A1:A9) and a data When (B1) is multiplied, this group of numbers is multiplied by this data respectively;
When two arrays (A1:A9 and B1:B9) are multiplied, it is Multiply the data in the corresponding positions of the first group of numbers and the second group of numbers.
Now look back at this formula=SUMPRODUCT((MONTH(F2:F22)=3)*(H2:H22="Second Branch")*(G2:G22="Shirt")* J2:J22)
, it should be less of a headache.
In fact, the calculation principles of arrays are more complicated. Friends who are interested can check out the relevant information. You can learn the simple principles here. Let’s take a look at the third formula: =SUMPRODUCT((H2:H22=H2)*(G2:G22={"sweater","shirt"})*L2:L22)
. This formula looks a little different from the previous two, (G2:G22={"sweater","shirt"})
This part uses a constant array. In fact, this formula should be written like this:=SUMPRODUCT((H2:H22=H2)*(G2:G22="Sweater")*L2:L22) SUMPRODUCT((H2:H22=H2)*(G2:G22="Shirt")*L2:L22 )
.
This formula uses two SUMPRODUCT functions. The first is to calculate the sales of sweaters in the main store, and the second is to calculate the sales of shirts in the main store. See respectively. Everyone should be able to understand. The two SUMPRODUCT functions are exactly the same except for "sweater" and "shirt". In this case, you can use a constant array to put the two contents together to make the formula simpler.
Through today's explanation, we have understood the common SUMPRODUCT formula, solved the confusion about using the multiplication sign of the SUMPRODUCT function, and mastered more applications of the SUMPRODUCT function. We also learned some basics about logical values and arrays - which will help us understand other complex formulas.
Related learning recommendations: excel tutorial
The above is the detailed content of The omnipotent SUMPRODUCT for learning Excel functions!. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



If when opening a file that needs to be printed, we will find that the table frame line has disappeared for some reason in the print preview. When encountering such a situation, we must deal with it in time. If this also appears in your print file If you have questions like this, then join the editor to learn the following course: What should I do if the frame line disappears when printing a table in Excel? 1. Open a file that needs to be printed, as shown in the figure below. 2. Select all required content areas, as shown in the figure below. 3. Right-click the mouse and select the "Format Cells" option, as shown in the figure below. 4. Click the “Border” option at the top of the window, as shown in the figure below. 5. Select the thin solid line pattern in the line style on the left, as shown in the figure below. 6. Select "Outer Border"

Excel is often used to process data in daily office work, and it is often necessary to use the "filter" function. When we choose to perform "filtering" in Excel, we can only filter up to two conditions for the same column. So, do you know how to filter more than 3 keywords at the same time in Excel? Next, let me demonstrate it to you. The first method is to gradually add the conditions to the filter. If you want to filter out three qualifying details at the same time, you first need to filter out one of them step by step. At the beginning, you can first filter out employees with the surname "Wang" based on the conditions. Then click [OK], and then check [Add current selection to filter] in the filter results. The steps are as follows. Similarly, perform filtering separately again

In our daily work and study, we copy Excel files from others, open them to add content or re-edit them, and then save them. Sometimes a compatibility check dialog box will appear, which is very troublesome. I don’t know Excel software. , can it be changed to normal mode? So below, the editor will bring you detailed steps to solve this problem, let us learn together. Finally, be sure to remember to save it. 1. Open a worksheet and display an additional compatibility mode in the name of the worksheet, as shown in the figure. 2. In this worksheet, after modifying the content and saving it, the dialog box of the compatibility checker always pops up. It is very troublesome to see this page, as shown in the figure. 3. Click the Office button, click Save As, and then

eWe often use Excel to make some data tables and the like. Sometimes when entering parameter values, we need to superscript or subscript a certain number. For example, mathematical formulas are often used. So how do you type the subscript in Excel? ?Let’s take a look at the detailed steps: 1. Superscript method: 1. First, enter a3 (3 is superscript) in Excel. 2. Select the number "3", right-click and select "Format Cells". 3. Click "Superscript" and then "OK". 4. Look, the effect is like this. 2. Subscript method: 1. Similar to the superscript setting method, enter "ln310" (3 is the subscript) in the cell, select the number "3", right-click and select "Format Cells". 2. Check "Subscript" and click "OK"

When processing data, sometimes we encounter data that contains various symbols such as multiples, temperatures, etc. Do you know how to set superscripts in Excel? When we use Excel to process data, if we do not set superscripts, it will make it more troublesome to enter a lot of our data. Today, the editor will bring you the specific setting method of excel superscript. 1. First, let us open the Microsoft Office Excel document on the desktop and select the text that needs to be modified into superscript, as shown in the figure. 2. Then, right-click and select the "Format Cells" option in the menu that appears after clicking, as shown in the figure. 3. Next, in the “Format Cells” dialog box that pops up automatically

Most users use Excel to process table data. In fact, Excel also has a VBA program. Apart from experts, not many users have used this function. The iif function is often used when writing in VBA. It is actually the same as if The functions of the functions are similar. Let me introduce to you the usage of the iif function. There are iif functions in SQL statements and VBA code in Excel. The iif function is similar to the IF function in the excel worksheet. It performs true and false value judgment and returns different results based on the logically calculated true and false values. IF function usage is (condition, yes, no). IF statement and IIF function in VBA. The former IF statement is a control statement that can execute different statements according to conditions. The latter

In the study of software, we are accustomed to using excel, not only because it is convenient, but also because it can meet a variety of formats needed in actual work, and excel is very flexible to use, and there is a mode that is convenient for reading. Today I brought For everyone: where to set the excel reading mode. 1. Turn on the computer, then open the Excel application and find the target data. 2. There are two ways to set the reading mode in Excel. The first one: In Excel, there are a large number of convenient processing methods distributed in the Excel layout. In the lower right corner of Excel, there is a shortcut to set the reading mode. Find the pattern of the cross mark and click it to enter the reading mode. There is a small three-dimensional mark on the right side of the cross mark.

1. Open the PPT and turn the page to the page where you need to insert the excel icon. Click the Insert tab. 2. Click [Object]. 3. The following dialog box will pop up. 4. Click [Create from file] and click [Browse]. 5. Select the excel table to be inserted. 6. Click OK and the following page will pop up. 7. Check [Show as icon]. 8. Click OK.
