Passing multiple values to SUMIFS function in Excel - excel

I have Twocolumns A, B ..I am trying to get the sum of A like below.
=SUMIFS(
sheet1!$A:$A,
sheet1!$B:$B, ("AB", "BC", "CD")
)
But this formula is not working.
Please suggest me.

Try to use following formula:
=SUMPRODUCT((sheet1!$B:$B={"AB","BC","CD"})*(sheet1!$A:$A))
or alternatively you can use an array formula:
=SUM(IF(sheet1!$B:$B={"AB","BC","CD"},sheet1!$A:$A,0))
enter formula in the formula bar and press CTRL+SHIFT+ENTER to evaluate it......

If I'm guessing your intention right, you should have:
=SUMIFS(sheet1!$A:$A,Sheet1!$B:$B,"AB")+SUMIFS(sheet1!$A:$A,Sheet1!$B:$B,"BC")+SUMIFS(sheet1!$A:$A,Sheet1!$B:$B,"CD")

Add two helper columns: in D:D you have the list of valid values. In C:C you have a formula like this (change ; to ,). In F1 you have your sum like this:
=SUMIFS($A:$A,$C:$C,FALSE)
Now you can add any number of valid criteria in column D:D.

You can use SUMIFS to return an array (one for each criterion) and then SUM to sum those, i.e.
=SUM(SUMIFS(sheet1!$A:$A,sheet1!$B:$B,{"AB","BC","CD"}))
This way retains the speed and efficiency of SUMIFS without needing repetition
If you have your criteria values in a range of cells you can simply reference the range, but use SUMPRODUCT to avoid "array entry"
=SUMPRODUCT(SUMIFS(sheet1!$A:$A,sheet1!$B:$B,Z2:Z4))
where Z2:Z4 contains the criteria
Note: in both of these SUMIFS does all the "heavy lifting" - SUM/SUMPRODUCT is used simply to sum the resulting array

Related

Excel Formula - Criteria To Concatenate multiple cells by matching source cell

I am Looking to concatenates multiple cells into one by Index-matching the criteria
The below formula is not pulling in all the required UPCs against the specified criteria
=INDEX($B:$B,MATCH($D:$D,$A:$A,0))
I would like the end result to look like COL E2 in the below image with semi-colons in between every value ;
Any help here would be much appreciated.
If you have Office365 then use TEXTJOIN() with FILTER() function.
=TEXTJOIN(";",TRUE,FILTER($B$2:$B$15,$A$2:$A$15=D2))
Edit: Assuming you don't have access to O365 dynamic formulas. Then try below array formula.
=TEXTJOIN(";",TRUE,IF($A$2:$A$15=D2,$B$2:$B$15,""))
Press CTRL+SHIFT+ENTER to evaluate the formula as it is an array formula.
An alternative approach using the CONCAT function:
=CONCAT(FILTER(B:B, A:A=D2)&";")
Explanation:
The FILTER logic is just like Harun24HR suggested. Creating an array of all the values in B where the value in A is equal to D2.
The & operator works on each element in the array and adds a delimiter ";" to each value.
Finally, the CONCAT function combines all of the elements in the array into a single string.

index and match multple criteria

I am trying to use index and match to find when two columns match another two columns then return another column in the same row. For example,
IF (Sheet1:ColA = Sheet2:ColA) and (Sheet1:ColB = Sheet2:Col B) then return Sheet2:ColC.
Here is what I have so far as my formula which does not work:
=INDEX('Sheet2'!C:C,MATCH(1,('Sheet1'!A1='Sheet2'!A1:A4)*('Sheet1'!B1='Sheet2'!B1:B4),0))
I want the "Wanted Col" values that are highlighted in the image.
Your formula seems correct, but it needs to be an Array formula. To achieve this; edit the formula through the formula bar and then press ctrl+shift+enter to set it as an array formula.
It should then look like this:
{=INDEX('Sheet2'!C:C,MATCH(1,('Sheet1'!A1='Sheet2'!A1:A4)*('Sheet1'!B1='Sheet2'!B1:B4),0))}
Alternatively, you can avoid using array formulas by adding a second index:
=INDEX(Sheet2!C:C;MATCH(1;INDEX((A1=Sheet2!A:A)*(B1=Sheet2!B:B);0;1);0))
If you have Office365 then you can use Filter() formula-
=FILTER(Shee2!$C$1:$C$4,(Shee2!$A$1:$A$4=A1)*(Shee2!$B$1:$B$4=B1))
Alternatively You can use INDEX() and SUMPRODUCT() together. Try below-
=INDEX(Sheet2!C:C,SUMPRODUCT(ROW(Sheet2!C:C)*(Sheet2!A:A=A2)*(Sheet2!B:B=B2)))

MAX value using lookup for comma-separated list in one of the columns in Excel

This formula is SO close to what I am looking for.
Keys Scores
k1 10 k1,k2
k2 15 k3
k3 8 k1,k2,k3
=SUMPRODUCT(SUMIFS(B:B,A:A,TRIM(MID(SUBSTITUTE(E2,",",REPT(" ",999)),(ROW($ZZ$1:INDEX($ZZ:$ZZ,LEN(E2)-LEN(SUBSTITUTE(E2,",",""))+1))-1)*999+1,999))))
It works great but instead of it providing a SUM of the Scores I like it to provide the max value of the Scores based on the comma separated string entered.
Can it be done?
Tried substituting MAX and MAXA for SUMPRODUCT
In this example my dep_val indicates the End Date that I want to reference to populate the Start Date while allowing only workdays and no holidays and it works well.
What I would like to do is enter a string such as 3,4,5 as the dep_val for Task 6 and have the formula return the MAX value End Date in Tasks 3,4,& 5.
Hope this clears things up.
You can use MAX() instead of SUMPRODUCT() but then you need to enter the formula as an array formula with Ctrl+Shift+Enter.
Formula solution for Excel 2013 or above in the use of FILTERXML function
Formula in F2, copied down :
=AGGREGATE(14,,LOOKUP(FILTERXML("<a><b>"&SUBSTITUTE(E2,",","</b><b>")&"</b></a>","//b"),A$2:B$4),1)
Edit: The above formula Lookup list must be sorted in ascending order because the using of LOOKUP function and it is a normal formula.
Or,
You can use the VLOOKUP function without sorting instead, and it is an array formula must confirmed with SHIFT+CTRL+ENTER entry
=MAX(VLOOKUP(T(IF({1},FILTERXML("<a><b>"&SUBSTITUTE(E2,",","</b><b>")&"</b></a>","//b"))),A$2:B$4,2,0))

Excel: find the Max of an array with same names

I have searched the Net and tried multiple solution which never worked. You are my last hope.
I have a table like that:
NAMES.......... VALUES
A...........................4
A...........................1
B...........................4
B...........................3
B...........................2
B...........................1
C...........................4
C...........................3
As you can see, the first column has names only where the second one values.
Both Names and Values often repeat them self.
The idea is to TAG the names (first column) with the MIN value taken from the second column.
So the correct result should be:
NAMES.......... VALUES
A...........................1
B...........................1
C...........................3
I am trying to do that through Excel using the INDEX+Match formula where I am trying to add a MIN formula without success:
=MIN(INDEX($D$25:$D$36,MATCH(C25,$C$25:$C$36,0),1))
I have put the MIN everywhere but none seems to work. Which is the correct syntax and if this is not the right solution, which formula might do the job?
Thank you for your time and help
With data in column A and B, in C1 through C3 enter:ABC then in D1 enter the array formula:
=MIN(IF(A$1:A$100=C1,B$1:B$100,""))
and copy down:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
If the data never changes, a Pivot Table is easier to implement.
Two non-array alternatives.
With the newer MINIFS function.
=minifs(d:d, c:c, c25)
Using INDEX in its array format but entered as a standard formula,
=min(index((d$25:d$36)+(c$25:c$36<>c25)*1e99, , ))

Excel SUM and IF combine help

I have two columns of numbers. Both are 1 to 5. I want to count all the cells where the left column value equals the right column value AND the left column value equals a certain value.
I tried this:
=SUM(IF(W2:W13=X2:X13 AND W2:W13=4,1,0))
I've tried pressing Ctrl+Shift+Enter and it adds {} around the formula but that didn't help either.
I think it's the W2:W13 = 4 part that doesn't work
=COUNTIFS(W2:W13,"=4", X2:X13, "=4")
You can use the sumif() function:
SumIf( range, criteria, sum_range )
it will apply the criteria for each row in the range.
Edit: to count the matches, you can use sum_range = 1 or use the Countif() function suggested by Ben in his answer
Have you considered a third column (C) with the formula IF(A1=B1,1,0) and then summing that third column?
I'm not much of an Excel Expert, but didn't they craeted the COUNTIF(range, criteria) function for this?
Add a third column eg Z2:Z13 with this formula: IF(AND(W2=X2; W2=4); 1; 0)
Then sum that one.
I don't have Excel 2007. So here's how you can do it in Excel 2003:
=COUNT(IF((W2:W14=4)*(X2:X14=4),Y2:Y14))
Since you are looking for a specific value and the column next to it to be the same value, you can just compare both columns to the same value.
The trick to get this to work is after entering the formula you need to hit F2 to go into edit mode and then hit CTRL-SHIFT-ENTER which makes this formula an array formula. This will put {} around the entire formula. Without making this an array formula this formula won't work.
I found this information in the Excel help document titled Count how often a value occurs

Resources