Using the array formula below {=MMULT(MMULT(C27:D27,(H27:I28)),TRANSPOSE(C27:D27))} I get 35.05425707.
Using the below array {=(MMULT(C27:D27,(H27:I28)))} I get 5.763564268.
Although I understand perfectly how the second formula output the value of 5.763564268 I do not understand how the 35.05425707 was output. Can I ask for a step by step breakdown? Please find a view of the file below:
Thank you in advance.
MMULT is an array formula and the first MMULT actually results in an array of 2 values:
=MMULT(B7:C7,G7:H8) returns an array of 5.7636 & 5.8818
When you do the second MMULT:
=MMULT(MMULT(B7:C7,G7:H8),TRANSPOSE(B7:C7))
You multiply 5.7636 by 2 and 5.8818 by 4. Added up that results in 35.0544.*
*(I used the screenshot for reference and the numbers are not matching, since the values shown are rounded values)
Related
I am struggling with an array formula, that logically seems sound, however it doesn't appear to be working correctly. I have been working on a complex sheet, that is not to include VBA, which has made it formula heavy, and using arrays instead.
In the image below, the first part is the problem, for the data shown in columns A-F, I wish to get a sum of the values that match the values in I1:K1.
The formula I have used to begin with can be seen in the first image also, this evaluates, pressing F9, to give me the desired output 20,40 & 50. However when I add the SUM around the formula, I only get the first result out.
I think this is an issue with me not seeing the wood for the trees on this one.
Thanks in advance.
This array formula seems to work:
=SUM((IFERROR(MATCH(A1:F1,I1:K1,0),0)>0)*A2:F2)
There are probably multiple better formulas to achieve the same thing.
But to talk about why this fails:
It is because of the OFFSET function returns a reference rather than a value. And so used in this array formula it returns an array of references {B2,D2,E2} instead of an array of values {20,40,50} which leads to the problem.
If you are using:
=SUMPRODUCT(OFFSET(A2,0,MATCH($I$1:$K$1,$A$1:$F$1,0)-1))
then using Evaluate Formula, you will get:
SUMPRODUCT({#VALUE,#VALUE,#VALUE})
in next to last step and 0 as the result. So the OFFSET leads to error values because of it returns an array of references which will not be dereferenced automatically and so will become #VALUE error each.
If you are using
=SUMPRODUCT(N(OFFSET(A2,0,MATCH($I$1:$K$1,$A$1:$F$1,0)-1)))
then it works and returns 110. So the N dereferences the references of each OFFSET and so the whole formula leads to an array of values {20,40,50} in sum.
{=SUM(N(OFFSET(A2,0,MATCH($I$1:$K$1,$A$1:$F$1,0)-1)))}
works too.
These problems occur using funktions like OFFSET and INDIRECT, which returns references rather than values, in array formulas. And having a dereferencing function around the OFFSET or INDIRECT stops the problems.
It is the same with:
=SUMPRODUCT(INDIRECT("R2C"&MATCH(I1:K1,A1:F1,0),FALSE))
versus
=SUMPRODUCT(N(INDIRECT("R2C"&MATCH(I1:K1,A1:F1,0),FALSE)))
My apologies if the title is not very clear (couldn't think of a better way to put my problem)...
I'm using a countif function to find all values that match two criteria, part type & code. The issue I'm having is that the criteria on part type is a range and when I try to evaluate this as an array formula, excel is only looking at the first value in the range. This is what the data looks like:
Sheet 1:
PART CODE
1 x
2 y
3 z
4 x
3 z
4 z
3 y
Sheet2:
1 Type A
2 Type A
3 Type B
4 Type B
I'm using a countif formula (as an array) to calculate the number of type B parts that have a code of "z". Here's the formula I used in Excel (PART & CODE are named ranges):
COUNTIFS(PART, 'Sheet2'!$B$3:$B$4, CODE,z)
This formula returns 2 instead of 3. When I evaluated this, Excel shows that it only finds the first value (y) and evaluates from there. I'm not sure why it is not seeing the second value (z) and evaluating that too. Any help on this would be great.
I did some more research and finally decided to try other functions (despite my initial thoughts that they wouldn't serve my purpose)...here's the final function:
SUMPRODUCT(IF(PART=TRANSPOSE(TypeA),1,0)*IF(CODES="z",1,0)
I had never used this function before and was thus confused when I initially read about it. After several hours of pulling my hair, I figured I had nothing to lose and forced myself to try and understand what it was accomplishing. I was so stuck on "counting" the number of occurrences that I failed to realize that by using this function with multiple IF statements, I could obtain the necessary answers (and save myself the hassle).
The TRANSPOSE function was used so that I could get the column array to be read horizontally like {1,2} instead of vertically {1;2}. I'm still not sure why my original function could not handle the vertical (unless I'm missing a fundamental aspect of arrays).
I am coming to seek guidance with another question with Excel Array Formulas.
I am using Excel 2003 and trying to understand a new spreadsheet with the following type of formula :
{=IF($B$6,SUM(($C$6:$AM$6=1)*1),)}
I have tried using the Excel formula audit tool to understand the formula but it crashes when I run it on these type of array formula.
As of now I am thinking that the formula does this :
B6 has a number = True / False
If True do SUM of (C6:AM6=1) and multiply by 1
If False do nothing
However, I am not 100% of the second statement. Does it say SUM the number of times 1 is present in C6:M6 then multiply by 1? If so why multiply by 1. My only guess on the latter is that the (C6:M6=1) returns a True or False value and the *1 converts it to 0 or 1. Then if this is correct, what is the purpose of the sum function?
Thanks for any guidance.
You are correct.
($C$6:$AM$6=1) returns an array of TRUE/FALSE values, which SUM would ignore.
Multiplying by 1 creates an array of 1/0 values, which are then added by SUM to create a count of the number of cells in the range that equal 1.
COUNTIF would be simpler as mentioned previously.
I think you do not need an array function. Try this non-array formula:
=IF($B$6,SUMIF($C$6:$AM$6,1,$C$6:$AM$6),"Do Nothing")
I have come across this formula which works in my application but I do not understand how it works
:=INDEX(MAX(($B:$B<>"")*(ROW(B:B))),0)
I have broken it down and found that:
=MAX($B:$B<>"") returns 1 regardless of what is the highest value in column B
=ROW(B:B) returns 1
if I input =MAX(($B:$B<>"")*(ROW(B:B))) as an array formula it returns the row number of the highest non blank cell.
However the INDEX formula does not seen to require an array formula input?
Can anyone please explain?
I'm trying to perform math within an Excel formula to specify the end of an array. Here is a simple version of what I want to do:
A B C
1 =COUNTA(A1:A5)-1 =SUM(A1:A(1+B1))
2
3
4
5
The first column is my data array. The second column counts the number of entries in that array (so if it isn't full, it returns a value less than 5). The third column sums the array starting with the first value and ending with the last entered value. Obviously with the SUM function it doesn't matter if there are zeroes, but I am trying to use the MATCH function and I don't want it to return a zero just because there are blank entries in the array I'm looking up.
So I want to modify the information within the SUM function to produce a variable array length based on the return value of B1. I hope this is clear. Thanks for any help!
One way is to use INDEX like this
=SUM(A1:INDEX(A:A,B1+1))
you can use the range defined by
A1:INDEX(A:A,B1+1)
in other functions like MATCH
Like this?
=SUM(INDIRECT("A1:A"&(1+B1)))