I'd like to create a formula that creates multiple arrays based on an if statement, multiplies the arrays, and then sums the products.
So if these are my arrays:
I'd like to sum their product if A doesn't equal 0. My current formula works, but I'd like to be able to do this with only one if statement.
=SUMPRODUCT(IF(A1:A5<>"",A1:A5%),IF(A1:A5<>"",B1:B5))
Try...
=SUM(IF(A1:A5<>"",(A1:A5%*B1:B5)))
...which needs to be confirmed with CONTROL+SHIFT+ENTER.
Related
So I'm using Countifs() because I have a few different criteria I want to check against a large dataset.
I want to take two series (e.g. A2:A10 and B2:B10), and count how many times the A number is bigger than the corresponding B number (A2 vs B2, A3 vs B3, etc.) while also checking that a third series (C2:C10) is equal to a certain value.
Here's a rough version of what I've tried:
=COUNTIFS(A2:A10,">"&B2:B10, C2:C10,"1/1/2018")
So for this example, it would return 2:
example data
I tried doing the Control+Shift+Enter for array formulas, but that didn't work.
EDIT: Thanks asher, you're right that formula does work with that example. But for some reason in this other example it doesn't: data . It uses times instead of normal numbers, but that shouldn't make a difference
You can use the following formula, which only needs to be confirmed with ENTER...
=SUMPRODUCT(--(A2:A10>B2:B10),--(C2:C10="1/1/2018"+0))
You can use SUM() + IF() in an ARRAY Formula as follows:
=SUM(IF(A2:A5>B2:B5,1,0)*IF(C2:C5=DATE(2018,1,1),1,0))
Confirm with CTRL+SHIFT+ENTER instead of ENTER only as is an array formula so you get the brackets:
{=SUM(IF(A2:A5>B2:B5,1,0)*IF(C2:C5=DATE(2018,1,1),1,0))}
Your logic works fine for me. In Cell E1, I have this:
=COUNTIFS(A2:A11,">"&B2:B11,C2:C11,"1/1/2018")
That yields 2. Or, you could do the same with SUMPRODUCT:
=SUMPRODUCT(--(A2:A8>=B2:B8),--(C2:C8=E1))
Cell E1 contains '1/1/2018'
I'm trying to perform a sumproduct function on two arrays. I'd like to find a way of asking excel to select the first array if the column match a certain value.
In my simplified case if the value is "1" pick the first array and perform sumproduct with the array below A ...something that prevent me from spending the day nesting if (obviously a formula like =SUMPRODUCT(IF(O4=1;F4:F8;IF(O4=2;G4:G8;IF(O4=3;H4:H8;IF(O4=4;I4:I8))));L4:L8) works but in my real case is no use)
=SUMPRODUCT((O4=$F$4:$I$4)*$F$4:$I$8*$L$4:$L$8)
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))
I'm looking to use an array formula to makes lists of students who have entered different events, but also need to split by gender.
I have the first array working where it lists the students in each event but can't seem to get the second condition to work properly.
Here is my working formula for the first event lists:
=IFERROR(INDEX($A$3:$A$502,SMALL(IF($C$3:$C$502=1,ROW($C$3:$C$502)-ROW($C$3)+1),ROWS($C$3:$C3))),"")
Here is my non-working attempt at the second one:
=IFERROR(INDEX($A$3:$A$502,SMALL(IF(AND($C$3:$C$15=1,$B$3:$B$15="F"),ROW($C$3:$C$15)-ROW($C$3)+1),ROWS($C$3:$C3))),"")
What am I doing wrong?
Try,
=IFERROR(INDEX($A:$A, aggregate(15, 6, row($3:$502)/(($C$3:$C$502=1)*($B$3:$B$502="F")), row(1:1))), text(,))
I have no idea why your sample formula had the criteria ranges going down to row 15; the ranges need to be the same.
Array formula do not like AND or OR use * and + respectively.
=IFERROR(INDEX($A:$A,SMALL(IF(($C$3:$C$15=1)*($B$3:$B$15="F")),ROW($C$3:$C$15)),ROW($A1))),"")
I have an array formula that looks like this:
{=SUMIF(C11:C23,budgets,F11:F23)}
What I want it to do is sum cells F11:F23 where cells C11:C23 are values within the named range budgets.
Right now budgets has two values: 10361 and 10300 (these are transaction codes). However, the formula seems to only work for the first code 10361 but not for the second one.
I don't want to use SUMIFS because I have multiple worksheets where I would like this array formula to work, and the codes may change so changing them in one place (the named range budgets) will make things easier.
Any ideas? I don't know VBA, so was hoping for a formula solution.
Use SUMPRODUCT with COUNTIF():
=SUMPRODUCT((COUNTIF(budgets,$C$11:$C$23)>0)*$F$11:$F$23)
Or you can use this array formula:
=SUM(SUMIF(C11:C23,budgets,F11:F23))
Being an array it needs to be entered with Ctrl-Shift-Enter when exiting edit mode instead of Enter. If done properly Excel will put {} around the formula.