Excel Array Formula Error - 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")

Related

Value output by formula - not sure why array formula EXCEL

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)

Excel formula: counting array elements with a criteria

I have an array, which is the result of the multiplication of two COUNTIF functions.
The result is {0,2,7,4,0}. I want to count the number of non-zero elements. I tried the following:
=COUNTIF(COUNTIF*COUNTIF,">0") <- here the two inner COUNTIFs are short for the complete formula
It did not work. I then tried the following, which did not work either.
=COUNTIF({0,2,7,4,0},">0")
I resorted to using the following array formula and it worked.
{=SUM(IF(COUNTIF*COUNTIF>0,1,0))}
Two questions:
does COUNTIF only accept cell reference but not constant array?
any solution other than array formula?
Thanks.
The first argument of COUNTIF must be a range, nothing else will do.
You can just enter this as an ordinary formula:
=SUM(--({0,2,7,4,0}>0))
However when the array comes from a calculation, you need to coerce it to process all the elements either
=SUM(INDEX(--(A1:A5>0),0))
or like #Jeeped with Sumproduct
=SUMPRODUCT(--(A1:A5>0))

Euler 004 - Excel. Why is this array not finding the largest palidrome?

=MAX(B2:AHQ901*--AND(LEFT(B2:AHQ901,1)=RIGHT(B2:AHQ901,1),MID(B2:AHQ901,2,1)=MID(B2:AHQ901,5,1),MID(B2:AHQ901,3,1)=MID(B2:AHQ901,4,1)))
Attempting Euler challenge 004 in Excel 2013.
I have set up a simple spreadsheet that sums all 3 digit numbers.
The above array should find the maximum number in this spreadsheet that is a palidrome, but returns #value.
Any suggestions?
If that formula returns #VALUE! as an array formula then somewhere in B2:AHQ901 is a non numeric value.
But there is also an issue with the using of AND in array context. The AND will be evaluated first with the whole array. It will not be evaluated for each array element. So the whole AND will be false if only one comparison is false in the whole array.
It should be:
{=MAX(IF(ISNUMBER(B2:AHQ901),B2:AHQ901)*
(LEFT(B2:AHQ901,1)=RIGHT(B2:AHQ901,1))*
(MID(B2:AHQ901,2,1)=MID(B2:AHQ901,5,1))*
(MID(B2:AHQ901,3,1)=MID(B2:AHQ901,4,1)))}

Excel COUNT() vs COUNTIF() with arrays

I think this should be a straightforward question, but for some reason I can't find a solution anywhere.
I have a lengthy formula in excel that, ultimately, returns an array of four items -- i.e. {1,2,0,0}. I want to count how many of the resulting numbers are greater than zero.
When I use =COUNT({1,2,0,0}) on this result, I get the expected answer of 4. But when I try to use =COUNTIF({1,2,0,0}, ">0") it pops up with an error saying that my formula has a problem.
Is there something I'm doing wrong? Is there an array equivalent for COUNTIF() ?
It appears the COUNTIF function only works on ranges, while the COUNT function can utilize an array.
Give SUMPRODUCT a try. Below is a slightly expanded form of your example which I used to test the formula. It basically checks to see if each value in the array is greater than 0, and if it is, it assigns it a value of 1. Then SUMPRODUCT goes through and adds up all the 1s to give you the total number of values greater than 0.
=SUMPRODUCT(IF({1,0,3,0,5,0,0,6,9,9,0,7,0}>0,1,0))
Probably the most concise way to accomplish this is to just convert the TRUE or FALSE value returned from the validation check into a number with the INT function. TRUE translates to 1 and FALSE translates to 0. Then SUM those 1's and 0's.
=SUM(INT({1,2,0,0}>0))
Or as Barry Houdini points out, you can coerce the boolean to an int with:
=SUM(({1,2,0,0}>0)*1)
Or:
=SUM(({1,2,0,0}>0)+0)

SUMIFS function having a sum range as a product of 2 ranges, Array Formulas

I'm trying to minimize creating uneccessary tables in Excel, and instead of creating a table to multiply columns A and B, can I do it within the IF formula? Perhaps using Array formulas?
I tried Ctrl + Shift + Enter to enter the following formula:
SUMIFS($A$1:$A$10*$B$1:$B$10,$C$1:$C$10,"Value")
however it did not work.
Basically, I want to sum the product of A & B (i.e A*B) if the value in C is equal to "value".
SumProduct is what you need
=SUMPRODUCT($A$1:$A$10,$B$1:$B$10,--($C$1:$C$10="Value"))
Entered as a standard (not array) formula
This formula checks if the value in Column C is equal to 4 in this example. If so, it returns the product, if not, it returns 0. You enter this formula in for example column D and drag it down.
=IF(C1=4;SUMPRODUCT(A1:B1);0)

Resources