How to execute sumproduct with two criteria? - excel

I need to create a formula in excel that returns the sum-product of two columns in a range, based on two conditions.
Considering a table of 4 columns (A;B;C;D), if any row in column A is equal to a given value (example="A") and any row in column B starts with "*", then multiply column C and D and sum these products.
Any suggestions on how to implement the formula?
I thought it could be the following formula but it doesn't work:
=SUMPRODUCT(--(A2:A12="A"); --(left(B2:B12;1)="*"); C2:C12; D2:D12)

You could use an array formula such as :
{=SUM((A2:A12="A")*(LEFT(B2:B12)="*")*C2:C12*D2:D12)}
Remember to validate with ctrl+shift+enter

Related

How do I sum a column based on multiple sets of OR criteria?

I have a table with a target sum column (ColA) and three columns to filter based on criteria. I've been using SUMIFS to calculate the sum of ColA based on the criteria columns Cols B through D however I notice I'm not doing this correctly.
One thing to note is that the criteria columns have varying amounts of criteria each (e.g. column B has more OR conditions than C)
My current formula is:
SUM(SUMIFS(table[ColA], table[colB], {"val1", "val2", "val3"}, table[colC], {"val1", "val2"}, table[colD], {"val1", "val2", "val3", "val4"}))
The result of this formula is incorrect after manually checking the sum in the underlying table. Any advice on how to sum a column based on a set of multiple OR values?
You will need to do a SUMPRODUCT which will get long:
=SUMPRODUCT(table[ColA]*
((table[colB]="val1")+(table[colB]="val2")+(table[colB]="val3")>0)*
((table[colC]="val1")+(table[colC]="val2")>0)*
((table[colD]="val1")+(table[colD]="val2")+(table[colD]="val3")+(table[colD]="val4")>0))
To understand, the * is the equivalent to AND, the + is equivalent to OR
Let's say your table is called Table1, starts in A1 with headers, and is 4 columns wide. In a cell somewhere to the right, let's say G2, you could enter this formula:
=AND(OR(B2={"val1","val2","val3"}),OR(C2={"val1","val2"}),OR(D2={"val1","val2","val3","val4"}))
leaving G1 blank, then your sum formula is just:
=DSUM(Table1[#All],1,G1:G2)
You could also break the criteria formula up into three cells, one for each column, using:
=OR(B2={"val1","val2","val3"})
=OR(C2={"val1","val2"})
=OR(D2={"val1","val2","val3","val4"})
in G2:I2 (either leave G1:I1 blank, or give them labels that do not match any of your table headers), then use:
=DSUM(Table1[#All],1,G1:I2)
You could try to use MATCH() nested in SUMPRODUCT():
Formula in F1:
=SUMPRODUCT(ISNUMBER(MATCH(B2:B6,{"Val1","Val2","Val3"},0)+MATCH(C2:C6,{"Val1","Val2"},0)+MATCH(D2:D6,{"Val1","Val2","Val3","Val4"},0))*A2:A6)

Sum column but include only cells that have matching criteria in multiple columns in same row

I have an Excel spreadsheet with four columns, call them A, B, C, and Value. What I want to do is sum the Value column but only include those cells that have a certain criteria matching in columns A, B and C.
An example, in English: SUM the values in the Value column that have a value of 6 in column A, a value of 10 in column B and a value less than 15 in column C.
Thanks
Make a table like the attached image in excel.
In B10 put:
=SUMIF(A2:A8,B14,B2:B8)
In the B14 put the criteria.
I was searching for the same thing but the multiple criteria were in a single column. In my case, I was using LibreOffice (which has the same syntax but uses ; instead of , as separators).
The solution is to sum multiple SUMIF
=SUMIF(A2:A8,"porshe",B2:B8)+SUMIF(A2:A8,"porshe",B2:B8)+SUMIF(A2:A8,"mazda",B2:B8)
If you want the OR operator on the sum.
If you want AND operator you need to use SUMIFS that has multiple criteria and ranges.
=SUMIF(B2:B8,"porshe",A2:A8,"electric",C2:C8)

How to sum corresponding values with same month and names of two columns in Excel?

The formula should sum up the column C based on Column A and B when two column value matches and displays the sum value only in the first cell D2 of Column D as shown in figure "60" & "67".
I am trying with SUMIFS but not getting the Output as required.
=SUMIFS(C2:C6;A2:A6;"A:A";B2:B6)
Try this formula in cell D2:
=IF(SUMPRODUCT(--($A$2:$A2&$B$2:$B2=$A2&$B2))=1,SUMPRODUCT(--($A$2:$A$6&$B$2:$B$6=$A2&$B2),$C$2:$C$6),"")
It should give expected output.
It might also be better/more efficient if you create a helper column (which stores concatenation results, instead of doing the concatenation multiple times in each formula).

Excel: Countif of Countif

I'd like to know if there's a way to calculate two countifs with different data and criteria in a single formula (not row by row or with pivot tables). Let the following example apply:
I have the following table: fields A, B and C for each item (ID). Table header starts in cell T1.
I'd like to know how many items have 2 or more fields (A, B, C) with a number greater than 5.
I'd create another column X and use the following formula row by row: (Example for row 2)
=COUNTIF(U2:W2;">5")
and for that new column X (with all the COUNTIF formulas) I would use another COUNTIF
=COUNTIF(X:X;">1)
Is there a way to concatenate both? (I guess with an array formula)
Thanks in advance!
Try
=SUMPRODUCT((((U2:U11>5)+(V2:V11>5)+(W2:W11>5))>1)*1)
or
=SUMPRODUCT(--(((U2:U11>5)+(V2:V11>5)+(W2:W11>5))>1))
You can also use SUM(IF()) as an array formula like below
=SUM(IF(((U2:U11>5)+(V2:V11>5)+(W2:W11>5))>1, 1, 0))
Above being an array formula needs to be committed by pressing Ctrl+Shift+Enter.

Excel formula to match two columns and use sum function to subtract corresponding values

Excel Screenshot
The formula should lookup value from column A in column D and then the corresponding values should be subtracted in G1 and so on.
thanks.
Try this:
=$B1-VLOOKUP($A1,$D:$E,2,0)

Resources