SUMPRODUCT with SUMIFS - excel

=SUMIFS($B:$B*$N:$N,$N:$N,">=5",$N:$N,"<10")
I want to multiply 2 columns and sum all instances of it, conditioned only on one of the columns.The formula gives an error because I multiply in the first argument, which just should be a single number I guess. I tried using SUMPRODUCT too, but as column B does not have a condition, it doesn't work. Can anyone advice please. Thanks in advance.

The equivalent SUMPRODUCT formula for your SUMIFS attempt is:
=SUMPRODUCT(B:B,N:N,--(N:N>=5)*(N:N<10))
But you should avoid using full column references in SUMPRODUCT. If you can't limit range sizes, consider using dynamic named ranges.

try:
=SUMPRODUCT(B:B,IF(N:N>=5,IF(N:N<10,N:N,""),""))
with array ctrl+shift+enter

Related

Excel - SUM or SUMIF all columns of a 2D array where rows are filtered by a horizontal function

I want to SUM multiple columns but only for rows whose SUM is >0. One approach that works is to add an extra column that in essence excludes rows whose SUM is <0 and then sum that extra column as in the screenshot below. My desire is to eliminate the helper column and create a single formula based only on the original data that returns the same result. I've tried to include FILTER() inside a SUMIF() and a few other possibilities but to no avail.
Note: I am on O365 with dynamic array support if that helps. Thanks in advance.
If I understand what you mean, using the MMult function will help convert the matrix A2:C4 to E2:E4 as you say.
-You can use the LET function, if you have Office365-Insider,
=LET(x,A2:C4,y,MMULT(x*1,SEQUENCE(COLUMNS(x))^0),SUM(y*(y>0)))
-Or missing LET:
=SUM(MMULT(A2:C4*1,SEQUENCE(COLUMNS(A2:C4))^0)*(MMULT(A2:C4*1,SEQUENCE(COLUMNS(A2:C4))^0)>0))
The reason I use x*1 is to avoid possible errors if you leave a cell blank.
In G2, enter formula :
=SUMPRODUCT((MMULT(A2:C4,{1;1;1})>0)*MMULT(A2:C4,{1;1;1}))

Get value using INDEX and MATCH

I need help in my formula, I'm getting #VALUE!.
I have 2 sheets, I need to get the data using 2 values, So I've searched and the solution is to use the INDEX and MATCH Function. I've tried that in my formula but I think I'm doing it wrong.
I have 3 columns in my Main Sheet,
In the column Total Amount I need to insert the formula.
And this is my 2nd sheet. 3 columns also.
And this is the formula that I've used,
=INDEX(Q9:Q13,MATCH(O19&P19,O9:O13&P9:P13,0))
I've tried to check using evaluate formula and I'm getting #Value! I don't know why.
Any Ideas?
Thanks!
I think SUMIF() would be best fit for you in this case. Try below formula.
=SUMIFS(Sheet2!$Q$8:$Q$13,Sheet2!$O$8:$O$13,A1,Sheet2!$P$8:$P$13,B2)
You can also use SUMPRODUCT() like below.
=SUMPRODUCT((Sheet2!$Q$8:$Q$12)*(Sheet2!$O$8:$O$12=A2)*(Sheet2!$P$8:$P$12=B2))

COUNTIF cells on a range that differ from those of another range based on a formula

What I'm trying to achieve is to count the number of cells on a range that differ from cells on another range by a given difference.
In the example: how many double bogeys (none), bogeys (1), pars (2) and birdies (1) there are in a scorecard. For counting, say, Bogeys, this would obviously work, but it's a ridiculous formula:
=COUNTIF(B10;B9+1)+COUNTIF(C10;C9+1)+COUNTIF(D10;D9+1)+COUNTIF(E10;E9+1)
I've tried many combinations of COUNTIF, COUNTIFS, MATCH... functions, but all return syntax errors.
Help would be appreciated.
Thank you.
Use SUMPRODUCT:
=SUMPRODUCT(--($B$10:$E$10-$B$9:$E$9=3-ROW(A1)))
The 3-ROW(A1) creates the sequence 2,1,0,-1 when dragged down.

External link with dynamic range in sumproduct

I'm trying to built a formula in excel in order to have a SUMPRODUCT in an external file. I have to "point" SUMPRODUCT in a different column every week. Example: during w32 SUMPRODUCT points on column AA, during w33 it points on column AB etc.
This is the working formula with SUMIFS and OFFSET:
=SUMIFS(OFFSET('[FEDE.xlsx]Avanzamento WO'!$AM$4;0;WEEKNUM(TODAY())-29;1000);'[FEDE.xlsx]Avanzamento WO'!$K$4:$K$1003;B5)
This is the working formula with SUMPRODUCT (with static range):
=SUMPRODUCT(--('[FEDE.xlsx]Avanzamento WO'!$K$3:$K$10000=B4);'[FEDE.xlsx]Avanzamento WO'!$AP$3:$AP$10000)
Can anyone help me?
Thanks in advance to everybody
Federico
Are you willing to use your original OFFSET formula? In such case, you can apply either:
=SUMPRODUCT(--('Avanzamento WO'!$K$3:$K$1000=B5),OFFSET('Avanzamento WO'!$AM$3:$AM$1000,0,WEEKNUM(TODAY())-29))
or (version 2):
=SUMPRODUCT(--('Avanzamento WO'!$K$3:$K$1000=B5),OFFSET('Avanzamento WO'!$AM$3,0,WEEKNUM(TODAY())-29,998))
Note that I am using a range that ends in row 1000. SUMPRODUCT formula requires all ranges (arrays) to be of the same size. Your original SUMIFS formula was ending with row 1,000 while SUMPRODUCT approach was ending with 10,000, so I wasn't sure which one was correct. Also your SUMIFS was pointing to cell B5 while SUMPRODUCT was analysing cell B4.
Results:
Oh and I am using , instead of ; so you would also need to have it adjusted :)

how to count multiple columns using countifs

I am putting in a formula to count the number of times a quote is required Indicated by the letter Q in a given column, when I put the formula in for one column I get the correct answer, but when I want to do it for multiple columns I get zero, can anyone help please?
the formula is
=COUNTIFS(D10:D29,"=Q",G10:G29,"=Q")
Try either
=SUMPRODUCT((D10:D29="Q")+(G10:G29="Q"))
or
=SUMPRODUCT(((D10:D29="Q")+(G10:G29="Q")>0)+0)
the former will count 2 if you have Qs in both D10 and G10 - the latter only counts each row once at most, even if there are two "Q"s
countifs criteria are connected by a logical AND. so that formula is saying it must find your string in column D AND in column G. Apparently there are 0 instances of that. if you want the total number of cells with it then make it one range.
If the must be non-contiguous, use multiple countif formulas and add them
as a note, here I would change my formula back to countif, instead of countifs for backwards compatibility since I don't use the extra criteria.
EDIT: my second example was incorrect (See comments) so I removed it
Actually, what I've found is that there is a way better way instead of the sumproduct, which can result in a overly-long formula if you have 5 columns. Instead, I found that using the SUM+IF function as we use the SUMPRODUCT, will achieve the result faster and better.
=SUM(IF((E:I="ABC")*(B:B="DEF"); 1; 0))
This function returns the number of rows that contain both "ABC" and "DEF" in the defined columns.
Spread the word!

Resources