I have some columns and i need pr line to add say from O:S and then multiply with corresponding values from column N
So first sum from O:S then multiply with N:N
I could do
=SUMPRODUKT(N:N;O:O) + SUMPRODUKT(N:N;P:P) + SUMPRODUKT(N:N;Q:Q) + SUMPRODUKT(N:N;R:R) + SUMPRODUKT(N:N;S:S)
so I multiply N with each of the columns O to S but im sure there is a better way !
Specialy since it could be from S through QQ and that would be one boring formula to write
=SUMPRODUKT(HVIS.FEJL(N:N*O:Q;0))
' or in English
=SUMPRODUCT(IFERROR(N:N*O:Q,0))
Thank you #VBasic2008 and #mayukh-bhattacharya
SUMPRODUCT: The Multiplier of Arrays
As expected, it's as easy as:
=SUMPRODUCT(N:N*O:S)
Here's a small visual study I 'conducted':
Related
I made this Excel sheet to calculate total distance of a particular route and to keep track of trips. However, it makes many calculations which will eventually make it very slow (even more if routes have many stops).
In the image, Column P is the distance between PLACE_1 and PLACE_2, Column Q is the distance between PLACE_2 and PLACE_3 and so on. Column O is the sum of all these distances.
I used =INDEX(distance_table, MATCH(), MATCH()) to find the distances
This is the distance_table (distances are not real, just an example):
So as you can see, it works but it is very inefficient, the index/match formula will be used 10 times per trip.
What could be done to improve it? (considering there could be more than 10 stops per trip)
Thanks in advance!
You can use SUM/INDEX/MATCH/MATCH array formula:
=SUM(IFERROR(INDEX($B$2:$J$10,N(IF(1,MATCH($A$15:$J$15,$A$2:$A$10,0))),N(IF(1,MATCH($B$15:$K$15,$B$1:$J$1,0)))),0))
Array formula after editing is confirmed by pressing ctrl + shift + enter
Not intended as an answer. because in terms of performance index/match is faster, just as an alternative and maybe it can give you ideas:
Setup:
Formula:
=SUMPRODUCT(($B$6:$B$14=B3)*($C$5:$K$5=C3);$C$6:$K$14) +
SUMPRODUCT(($B$6:$B$14=C3)*($C$5:$K$5=D3);$C$6:$K$14) +
SUMPRODUCT(($B$6:$B$14=D3)*($C$5:$K$5=E3);$C$6:$K$14) +
SUMPRODUCT(($B$6:$B$14=E3)*($C$5:$K$5=F3);$C$6:$K$14) +
SUMPRODUCT(($B$6:$B$14=F3)*($C$5:$K$5=G3);$C$6:$K$14) +
SUMPRODUCT(($B$6:$B$14=G3)*($C$5:$K$5=H3);$C$6:$K$14) +
SUMPRODUCT(($B$6:$B$14=H3)*($C$5:$K$5=I3);$C$6:$K$14) +
SUMPRODUCT(($B$6:$B$14=I3)*($C$5:$K$5=J3);$C$6:$K$14) +
SUMPRODUCT(($B$6:$B$14=J3)*($C$5:$K$5=K3);$C$6:$K$14)
The formula I would like to use looks something like this: SUMPRODUCT(x^(1:n),y^(n:1)). n=values in column A. 1:n is the exponents in forward progression from 1 to n in steps of 1. n:1 is the exponents in reverse progression from n to 1 in steps of 1. I would like the formula to be dynamic to fill in column B with the n values based on column A.
Try:
=SUMPRODUCT(5^ROW(1:100))
Or in Excel O365
=SUM(5^ROW(1:100))
As per #RonRosenfeld, a more sturdy solution could be =SUM(5^SEQUENCE(100)) in Excel 365.
EDIT: Based on OP's comments he could use (no O365):
=SUMPRODUCT(5^ROW(A1:INDEX(A:A,COUNTA(A:A))),7^LARGE(ROW(A1:INDEX(A:A,COUNTA(A:A))),ROW(A1:INDEX(A:A,COUNTA(A:A)))))
You can store the powers in a column and use the array formula:
SUM((A1:A100)^$B$1) where A column contains 5 in each cell and B column contains the range of powers you want to use. You can use an array formula in the different cell to get the answer.
Use the SERIESSUM function
The Excel SERIESSUM function returns the sum of a power series, based on the following power series expansion:
Power Series Equation
The syntax of the function is:
SERIESSUM( x, n, m, coefficients )
Where the function arguments are:
x - The input value to the power series.
n - The first power to which x is to be raised.
m - The step size that n is increased by, on each successive power of x.
coefficients - An array of coefficients that multiply each successive power of x.
The number of values in the supplied coefficients array defines the number of terms in the power series. This is illustrated in the following examples.
Example 1:
In the spreadsheet below, the Excel Seriessum function is used to calculate the power series:
5^1 + 5^2 + 5^3 + 5^4 + 5^5
formula: =SERIESSUM( 5, 1, 1, {1,1,1,1,1} )
output = 3905
Example 2:
1 * 2^1 + 2 * 2^3 + 3 * 2^5 + 4 * 2^7 + 5 * 2^9
formula: =SERIESSUM( 2, 1, 2, {1,2,3,4,5} )
output = 3186
I hope this is of help.
An Alternative Answer again. I think the correct for your case :-)
Using the SERIESSUM function allows the use of different coefficients therefore the reason for the use of the coefficients in an array. But because the coefficients are the same then this is simply a geometric progression.
The following formula will do that for you:
=n+n*(n)^(1)*(1-(n)^c)/(1-n)
where "n" is the number (5) and "c" is the number of the series (100)
This becomes:
=5+5*(5)^(1)*(1-(5)^100)/(1-5)
=SUMPRODUCT(5^ROW(A1:INDEX(A:A,COUNTA(A:A))),7^LARGE(ROW(A1:INDEX(A:A,COUNTA(A:A))),ROW(A1:INDEX(A:A,COUNTA(A:A)))))
This formula worked flawlessly!!!
Thank you #JvdV and everyone else for your efforts in helping me! GREATLY APPRECIATED!
Following from the example here I'm trying to add additional conditions to a sum formula. I've represented an example below:
The output that I'm looking for for example for Jan 2017 is
2017
1
UP A 1
UP B 6
UP C 6
DOWN A 1
DOWN B 8
DOWN C 7
I tried with the following formula:
=MMULT(--($B$17:$C$17="X"),MATCH(1,($A23=$C$2:$C$14)*(C$21=$A$2:$A$14)*(C$22=$B$2:$B$14)*($E$2:$E$14=$D$2:$D$14),0))
but I get a N/A value.
Does anyone know it if is possible to do it?
In your first example the number of rows in array1 and number of columns in array2 were equal, five. Here you have two columns and 13 rows. That they are unequal here is part (all) of the reason why you are having an issue.
Also your match function is returning a Boolean not an array
I have a way to do this using matrix condition and multiple criteria but had to change problem up a bit, see photo for example:
{=MMULT(--(D18:P18="x"),E$2:E$14*(--(A$2:A$14=$C$21)*--(B$2:B$14=$C$22)*--(C$2:C$14=A24)))"
https://i.stack.imgur.com/FEvgR.png
You can create a formula to fill the second matrix with X's see below
=IF(OR(INDIRECT("D"&VALUE(D20))=$A$18,INDIRECT("D"&VALUE(D20))=$B$18),"X","")
https://i.stack.imgur.com/4rS4L.png
That being said I don't think this is particularly efficient as you are treating the one of the matrixes as a all 1's so you basically just adding an extra criteria / Boolean with added complexity....that being said u asked for this specifically and I believe that I have delivered that LOL
Just add two SUMIFS together.
=SUMIFS($E$2:$E$14, $A$2:$A$14, C$21, $B$2:$B$14, C$22, $C$2:$C$14, $A23, $D$2:$D$14, IF(INDEX($B$17:$C$19, MATCH($B23, $A$17:$A$19, 0), 1)="x", $B$16))+
SUMIFS($E$2:$E$14, $A$2:$A$14, C$21, $B$2:$B$14, C$22, $C$2:$C$14, $A23, $D$2:$D$14, IF(INDEX($B$17:$C$19, MATCH($B23, $A$17:$A$19, 0), 2)="x", $C$16))
I've been struggling with something in excel which is quite easy to do individual cases of using an array, but I want to do in a single cell.
Effectively, in row C I have the multipliers I need, lets call them i_k, for j from 1 to n. The equation I want to calculate in mathematical notation is;
Sigma(from j = 0 to n) (Pi(from k = j to n) (i_k))
But I'm not quite sure how best to go about this. Effectively it should be;
(i_1)^n + (i_2)^(n-1) + (i_3)^(n-2) + ...
In the end. Any help?
I dont know if this is an elegant solution but I think this might solve it for you.
The key is to make a table so that your formulas continue.
The screenshot I have taken explains the formula I have used with its explanation I have used on top of it.
-- The first column will have the intended values of I
-- The second column's first row will have the value of N
-- The third column will have a formula which says:
=IF(ISNUMBER([#[Values of N]]),[#[Values of N]],C2-1)
This will give you the decreasing value of N
Now just multiply N with I on the 4th column using a simple multiplication and add the final result:
I have two workbooks in excel which I copy columns from one to the other.
I would like to copy the number of one column, say A, IF another column, say B, is equal to "Test Tool" or "Hard Tool". I've written this code and can't get it to work, it just gives me the sum zero which is wrong. The last argument doesn't matter so ignore it.
"=SUMIFS('Tooling forecast template'!R6C17:R500C17,'Tooling forecast template'!R6C7:R500C7,""OR(=Test Tool, =Hard Tool)"" ,'Tooling forecast template'!R6C6:R500C6,""<>Actual tool/equipment change"")"
Here is a method that saves you typing out a large number of SUMIF statements, although it doesn't stop Excel having to calculate the multiple SUMIFs...
=SUM( SUMIFS('Tooling forecast template'!R6C17:R500C17,'Tooling forecast template'!R6C7:R500C7, {"Test Tool", "Hard Tool"} ,'Tooling forecast template'!R6C6:R500C6,"<>Actual tool/equipment change") )
Basically, you calculate the SUMIF with an array of values as your criteria, then wrap that SUMIF in a SUM so that the multiple answers are added together.
This example is quite hard to read due to the long variable names. Here's a simpler example, where you want to add up some numbers where the corresponding letter is either A or B...
The long way:
=SUMIFS(B1:B5, A1:A5, "A") + SUMIFS(B1:B5, A1:A5, "B")
The short way:
=SUM( SUMIFS(B1:B5, A1:A5, {"A","B"}) )
=IF(OR(CellToCheck="Test Tool", CellToCheck="Hard Tool"), CellToCopy, 0)
Just add the two SUMIFS together, its the same thing!
=SUMIFS('Tooling forecast template'!R6C17:R500C17,'Tooling forecast template'!R6C7:R500C7,"=Test Tool" ,'Tooling forecast template'!R6C6:R500C6,"<>Actual tool/equipment change") + SUMIFS('Tooling forecast template'!R6C17:R500C17,'Tooling forecast template'!R6C7:R500C7,"=Hard Tool" ,'Tooling forecast template'!R6C6:R500C6,"<>Actual tool/equipment change")
Use the fact that A OR B is the same thing as NOT ((NOT A) and (NOT B)). For example, sum the entries in A if B=1 or C=1 using SUMIFS:
=SUM(A1:A10) - SUMIFS(A1:A10,B1:B10,"<>0",C1:C10,"<>0")
You can achieve the same result with SUMPRODUCT:
=SUM(A1:A10) - SUMPRODUCT(A1:A10,--(B1:B10<>0),--(C1:C10<>0))
Wouldn't this work as well?
Note:
Assuming Col A houses values to be summed.
Assuming Col B houses the tool types.
=SUM(SUMIFS(A:A,B:B,"hard tool"),SUMIFS(A:A,B:B,"test tool"))