I'm trying to use TRANSPOSE inside SUMPRODUCT. What's wrong with my formula?
I use Excel 2013 if that matters.
Your formula is correct, you just need to press Crtl+Shift+Enter to confirm it and make it an array formula. In some cases SUMPRODUCT will sometimes automatically handle array treatment of arguments, but a TRANSPOSE argument apparently is not among them.
I'm not sure what result you want but would be interested to know whether:
=MMULT(D9:F9,D3:D5)
entered with Ctrl+Shift+Enter is such.
Related
Is there an Excel equivalent of the Javascript reduce function? Essentially, I want to apply a function to each cell in a range, and then sum up each result.
The reason I ask is because I have the following sheet:
For each expense, I'm calculating the "change", i.e. the amount needed to round it up to the nearest pound. I'm then summing that at the bottom.
I want to be able to do this without having the extra column and summing those values.
Thanks.
Use SUMPRODUCT(it avoids the need of Ctrl-Shift-Enter) and ROUNDUP(just shorter, personal preference):
=SUMPRODUCT(ROUNDUP(C3:C7,0)-C3:C7)
OK, so I just found out there's something called an array formula where you type your formula and then press Ctrl+Shift+Enter (and it'll put curly brackets around your formula to show that it worked).
So for my example above, I'd type
=SUM(CEILING.MATH(C3:C7)-C3:C7)
Then press Ctrl+Shift+Enter and it'd change it to
{=SUM(CEILING.MATH(C3:C7)-C3:C7)}
and that gives me the £2.11 I'm expecting.
I want to combine a formula that disregards cells where there is a 0 in order to average and also to disregard cells where there is an error such as DIV/0.
I have these two formulas which achieve either of these functions but not both. How would I combine them?
{=AVERAGE(IF(ISNUMBER(M2:P2),M2:P2))}
=AVERAGEIF(M2:P2,"<>0")
You would simply add the criterion of the second to the first:
=AVERAGE(IF(ISNUMBER(M2:P2)*(M2:P2<>0) ,M2:P2))
This is still an array formula and as such needs to be confirmed with Ctrl-Shift-Enter instead of Enter. If done properly then Excel will put {} around the formula.
you could use an if() to check for either condition then use the appropriate average function.
#Scott : better than mine...
I have two sheets with the same line of cells, for example, A1:A5.
I need to check if the value of every cell in Sheet1!A1:A5 is equal to Sheet2!A1:A5 but the hitch is the values will be letters, and all values are different. Simply typing the formula got me a #VALUE! error.
I know I can just write the formula:
=IF(Sheet1!A1=Sheet2!A1;1;0)
and then simply retype it in a number of cells with different values, but I'm looking for a way to shorten the formula.
Any suggestions?
To shorten the formula use array function. With that you will be able to check the whole range at once.
=IF(AND(Sheet1!A1:A5=Sheet2!A1:A5);1;0)
After typing the formula press Ctrl+Shift+Enter instead of just Enter key to confirm array formula.
This one is a little shorter
=(Sheet1!$A1=Sheet2!$A1)
You could use
AND(EXACT(Sheet1!A1, Sheet2!A1), EXACT(Sheet1!A2, Sheet2!A2), EXACT(Sheet1!A3, Sheet2!A3), EXACT(Sheet1!A4, Sheet2!A4), EXACT(Sheet1!A5, Sheet2!A5))
But in the following way:
Have a separate column with the code (let's say, column G)
EXACT(Sheet1!$A1, Sheet2!$A2)
To the column next to that, have a single cell with the code
AND(G1:G5)
Use the AND() function:
IF(AND(Sheet1!A1=Sheet2!A1,Sheet1!A2=Sheet2!A2,Sheet1!A3=Sheet2!A3,Sheet1!A4=Sheet2!A4,Sheet1!A5=Sheet2!A5),1,0).
EDIT
Not realy sure about your aim,
If you want it short because it is too difficult to write the above function, then try the method below:
=IF(CONCATENATE(Sheet2!A1,Sheet2!B1,Sheet2!C1,Sheet2!D1,Sheet2!E1)=CONCATENATE(Sheet1!A1,Sheet1!B1,Sheet1!C1,Sheet1!D1,Sheet1!E1),1,0)
But this is not without catch, it could return false positive. So use it with care. To overcome the false positive, I could only make the formula longer (but still relatively easy to write out).
=IF(CONCATENATE(Sheet2!A1,"|",Sheet2!B1,"|",Sheet2!C1,"|",Sheet2!D1,"|",Sheet2!E1)=CONCATENATE(Sheet1!A1,"|",Sheet1!B1,"|",Sheet1!C1,"|",Sheet1!D1,"|",Sheet1!E1),1,0)
Basically, I want to do a SUMIF, but I need to enter an equation for sum_range parameter, so normally, to do a SUMIF, you write:
=SUMIF(CRITERIA_RANGE,CRITERIA,SUM_RANGE)
This is great, but what if I need to do some calculation in my summation? So for example:
=SUMIF(CRITERIA_RANGE,CRITERIA,COL1*COL2)
Is something like this possible?
SUMPRODUCT is commonly used in this case
Eg
=SUMPRODUCT((CRITERIA_RANGE=CRITERIA)*COL1*COL2)
A different answer (NOT FOR POINTS).
Explanation
The reason why you cannot use SUMIF in your scenario is because SUMIF cannot handle Arrays as sumproduct does and hence I would go with Chris's suggestion of using SUMPRODUCT
Alternative
Here is one more way to achieve what you want.
=SUM(IF(CRITERIA_RANGE=CRITERIA,COL1*COL2,""))
ScreenShot
Please note that this is an ARRAY FORMULA which means that instead of pressing ENTER, you have to press CTRL+SHIFT+ENTER
I am using Excel to do some dot product between two row vectors:
=MMULT(B1049:M1049, TRANSPOSE(B1050:M1050))
But it does not work, as the cell for the formula shows "#VALUE!". I wonder why? Thanks!
Note that all the cells in "B1049:M1049" and "B1050:M1050" are numbers.
PS: Is this question more suitable here or Superuser?
probably simpler, you can just use =SUMPRODUCT(vec1,vec2).
This is exactly the Euclidean inner product, without resorting to array formulas.
you need to enter MMULT as an array formula, not as a standard formula
rather then hit enter when you type the formula in pres
ctrl-shift-enter
and excel will enter it as an array
it will end up looking like
{=MMULT(B1049:M1049, TRANSPOSE(B1050:M1050))}
(please note you can't enter the {} manually)
You may want to look at Excel help which covers this well