当前位置:网站首页>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

  1. 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

 Insert picture description here

  1. 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 ;
     Insert picture description here

  2. Find the total sales volume , Input =SUMPRODUCT(B2:B11,C2:C11)

Two 、 Summation of separated columns

  1. 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 .
     Insert picture description here

  2. 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

  1. 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
     Insert picture description here

  2. 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)
     Insert picture description here

  3. 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

  1. Image input =SUMPRODUCT((B2:B16>=80)*(C2:C16>=80))
     Insert picture description here

  2. 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

  1. 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;
     Insert picture description here

原网站

版权声明
本文为[qq_ forty-one million five hundred and fifty-four thousand six ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202210507362216.html