当前位置:网站首页>Classic usage of the sumproduct function
Classic usage of the sumproduct function
2022-06-25 05:31:00 【qq_ forty-one million five hundred and fifty-four thousand six 】
SUMPRODUCT The function is excel07 A function added after version , Versatile and powerful , yes excel A shining star in , Today, let's look at the usage of this function .
grammar :=SUMPRODUCT(array1,array2,array3, …),Array Is an array .
In a given set of arrays , Then multiply the elements of the array , Finally, we return the sum of the products .
SUM It means to sum ,PRODUCT It means quadrature , Together means the sum of products .
Several classic uses of functions :
One 、 And SUM Function usage comparison
example : Find the total sales quantity in the figure below , SUMPRODUCT(B2:B11)=SUM(B2:B11)
Find the total sales amount :=SUMPRODUCT(B2:B11*C2:C11) enter
perhaps =SUM(B2:B11*C2:C11) Press Ctrl+Shife+Enter Three keys end

SUMPRODUCT Function supports array operation , There is no need to press Ctrl+Shife+Enter Three keys end , Its operation principle is
When SUMPRODUCT When the arguments of the function are two arrays , You can use a multiplication sign or a comma in the middle , Or you could write it as =SUMRPODUCT(B2:B11,C2:C11) Multiply the corresponding elements between arrays , And then sum up , Above picture =SUMPRODUCT(B2:B11C2:C11)=SUMPRODUCT(B2:B11,C2:C11)=B2C2+B3C3+B4C4+······+B11*C11
The difference between using a multiplication sign and using a comma is in , When there is text in an array , Use the multiplication sign in the middle to get the wrong value , Because the text cannot participate in the calculation , At this time, the middle can only be separated by commas , Then the text will be treated as 0 To deal with it ;

Find the total sales volume , Input =SUMPRODUCT(B2:B11,C2:C11)
Two 、 Summation of separated columns
example : seek 1、2、3、4 Sum of planned quantity of the month , stay N3 Input =SUMPUDUCT((MOD(COLUMN(B3:M3),3)=2)*B3:M3), Drop down fill .

paraphrase :COLUMN function , Returns the number of columns in the selected cell , Such as the input =COLUMN(B5), The result is 2, intend B5 The cell is the second column , Input =COLUMN(G17), The result is 7, intend G17 The cell in which it is located is the 7 Column ,COLUMN(B3:M3), intend B3 To M3 Number of columns , Get the results {2,3,4,5,6,7,8,9,10,11,12,13}
MOD function , A function used to find the remainder , Returns the remainder of the division of two numbers , Input =MOD(5,2), The result is 1, intend 5 Divide 2 The remainder is 1, Input =MOD(17,3), The result is 2, intend 17 Divide 3 The remainder is 2,MOD(COLUMN(B3:M3),3)=2, intend B3:M3 Divide the number of columns by 3, The remainder is 2 Cells of , And what you get is {TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE,FALSE,FALSE}, In this TRUE It's true , Consistent with the results ,FALSE For false , Does not meet the results . In calculation TRUE As a 1 Calculation ,FALSE Press 0 Calculation
Calculation formula :=SUMPRODUCT((MOD(COLUMN(B3:M3),3)=2)*B3:M3)
=SUMPRODUCT({1,0,0,1,0,0,1,0,0,1,0,0}*{68,81,13,70,83,13,107,71,-36,85,118,33})=330
Element one between two arrays One corresponds to multiply and then sum .
In this example, you can also use SUMIF function ,N3 Input in =SUMIF($B 2 : 2: 2:M 2 , 2, 2,K$2,B3:M3) Drop down fill , Be careful B2:M2 Absolute reference to ;
without “ plan 、 actual 、 differences ” Where the line is ( Delete the second line ), You can't use SUMIF function , use SUMPRDUCT The function is better
3、 ... and 、 To sum by many conditions
Formula usage :=SUMPRODUCT( Conditions 1 Conditions 2 Conditions 3*······ Conditions N) , Multiple conditions in the formula are multiplied .
example : Find... In the figure below 2017 year 3 month 2 Nichong Ji 21 The amount of computer sales per hour , Input =SUMPRODUCT((A2:A18=–“2017/03/02”)(B2:B18=“ The computer ”)(C2:C18=“ Acer 21 " ”)*F2:F18) Double minus sign before date “–” It is used to convert logical values

seek 2017 year 3 month 3 Millet, 5.5 The amount of mobile phone sales per hour , Input =SUMPRODUCT((A2:A18=–“2017/3/3”)(B2:B18=“ mobile phone ”)(C2:C18=“ millet 5.5 " ”)*F2:F18), Add a double minus sign before the date
You can also use SUMIFS function , Input =SUMIFS(F2:F18,A2:A18,“2017/3/3”,B2:B18,“ mobile phone ”,C2:C18,“ millet 5.5 " ”)
The figure below shows the total sales volume in Northeast and Northwest China , Input =SUMPRODUCT(((A2:A10=“ The northeast ”)+(A2:A10=“ The northwest ”)),B2:B10)

Add the first two conditions ,=SUMPRODUCT(((A2:A10=“ The northeast ”)+(A2:A10=“ The northwest ”)),B2:B10)
=SUMPRODUCT((A2:A10=“ The northeast ”),B2:B10)+SUMPRODUCT((A2:A10=“ The northwest ”),B2:B10)
Four 、 Multi condition counting
Image input =SUMPRODUCT((B2:B16>=80)*(C2:C16>=80))

paraphrase : The first condition B2:B16>=80, When B2:B16 The area is qualified >=80 when , Show 1, Otherwise, it will show 0, The other condition is the same
=SUMPRODUCT((B2:B16>=80)*(C2:C16>=80))
=SUMPRODUCT({0;1;1;0;1;1;0;0;0;0;0;0;1;1;0}*{1;1;1;1;1;1;0;0;0;0;0;1;0;1;0}) Multiply two pairs and sum them
This example can also be used COUNTIFS function , Input =COUNTIFS(B2:B16,">=80",C2:C16,">=80")
5、 ... and 、 Condition ranking
The following figure , Ranking , stay C2 Input =SUMPRODUCT(($B 2 : 2: 2:B$16>B2)*1)+1 Fill down
The meaning of the formula : stay B2:B16 In the region , multiply 1, Convert it into an array to participate in the operation , Add 1(+1) It's kanbi B2(79) There are several large numbers of achievements , If there is 6 individual , be B2 What's your ranking 7;

边栏推荐
- 2022.1.21 diary
- Go implements LRU cache
- Professional things use professional people
- A summary of the experiment of continue and break in C language
- Monkey test of APP automation
- Enhanced paste quill editor
- "APEC industry +" biov Tech talks about the cross-border of Chinese biotechnology enterprises and "Pratt & Whitney Kangyu" | apec-hub public welfare
- CUDA compilation error
- Fundamentals of C language
- Database overview
猜你喜欢

Array introduction plus example 01

Array and simple function encapsulation cases

Unsupervised domain adaptation in semantic segmentation:a review unsupervised domain adaptation in semantic segmentation: a review

Only these four instructions are required to operate SQL data

C language -- Sanzi chess

Ranorex Studio 10.1 Crack

Small sample learning data set

2021-03-23

Monkey test of APP automation

2022.1.21 diary
随机推荐
2021-04-02
Basic knowledge of web pages (URL related)
[pan Wai 1] Huawei computer test
Go Context - Cancelation and Propagation
Ctfhub eggs
Edge loss 解读
2022.1.21 diary
Notes on non replacement elements in the line (padding, margin, and border)
Two dimensional array and function call cases of C language
Only these four instructions are required to operate SQL data
Common cluster deployment schemes in redis
Go Concurrency
Array introduction plus example 01
Prototypical Networks for Few-shot Learning
Could not find “store“ in the context of “Connect(homePage)
SSRF-lab
CTFHUB SSRF
Read the general components of antd source code
hr竟主动给这位测试小姐姐涨工资,她是怎么做到的?
Semantic segmentation cvpr2020 unsupervised intra domain adaptation for semantic segmentation through self supervision