Summing a Column in Excel 2010 based on multiple criteria - excel

InExcel 2010, I need to sum one column if another column is equal to a month and another colums is equal to "N" I have part of the answer, I just need to add the second criteria and the normal Sumifs does not seem to work with this because of the month issue.
The month is part of a full date format. eg 12 January 2014
This is what I ahve so far and it works :)
=SUM(IF(MONTH('MBR Tracker'!$AJ:$AJ)=1,'MBR Tracker'!$AO:$AO,0))
Regards
Pat J

You can use SUMPRODUCT which will work without array entry:
=SUMPRODUCT('MBR Tracker'!$AO:$AO * (MONTH('MBR Tracker'!$AJ:$AJ) = 1) * ('MBR Tracker'!$AK:$AK = "N"))
Assuming that AK is the other column which should contain N.

You can use following array formula:
=SUM(IF((MONTH('MBR Tracker'!$AJ:$AJ)=1)*('MBR Tracker'!$AK:$AK="N"),'MBR Tracker'!$AO:$AO,0))
Note, since it's array formula, you need to press CTRL+SHIFT+ENTER to evaluate it.

Related

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))

SUMIF based on another worksheet name and month

I'm trying to write a formula and I can get it to work in parts, but not all together. I think I might need an array formula, with which I have no experience.
The formula should pull data from worksheet "2017". I want it to sum any numbers located in column R IF the value in column F or G of that row is "Name" AND the date in column N is in the month of January.
SUMIFS() do not like the OR when looking two different ranges so you will need to use SUMPRODUCT and limit the range to only the dataset:
=SUMPRODUCT(R1:R100,((G1:G100 = "Name")+(F1:F100="Name")>0)*(MONTH(N1:N100) = 1))
as per your comments your formula should be:
=SUMPRODUCT('2017'!R1:R100,(('2017'!G1:G100 = "Allison Jones")+('2017'!F1:F100="Allison Jones")>0)*(MONTH('2017'!N1:N100) = 1))
Avoid full column references as this is an array type formula and it will slow down the calculations.
I seriously misread the Q at my first attempt. What I ought to have suggested is:
=SUMIFS(R:R,F:F,"Name",N:N,">=42736",N:N,"<42767")+SUMIFS(R:R,G:G,"Name",N:N,">=42736",N:N,"<42767")-SUMIFS(R:R,F:F,"Name",G:G,"Name",N:N,">=42736",N:N,"<42767")
Not elegant but uses just the SUMIFS function to get to the result by adding all the cases where the "F" criterion applies to all the cases where the "G" criterion applies and subtracting the cases where both "F" and "G" criteria apply.
42736 and 42767 are the serial numbers in the 1900 date system for the start of January 2017 and the start of February 2017. The 'or equals' is to allow for the possibility that column N might include times.

How to find minimum and maximum values in Column B based on a specific string in column A?

I have a list of items in Column A and have corresponding year and month values in Column B and C respectively. I am looking to find the minimum and maximum year in Column B (based on specific value in Column A), then find the corresponding month in Column C (only for max and min value) and then generate and fill in a Start and End date in Column E and F respectively.
E.g. IF #Item = Laptop THEN FIND MIN,MAX of #YEAR and THEN FIND adjacent value in #Month. Finally formulate and display a date accordingly.
Could i achieve this using a formula or is it out of scope and is better achieved using a macro?
For the Start date, in E2:
=IF(A2<>A1,DATE(AGGREGATE(15,6,$B$1:$B$1000/($A$1:$A$1000=A2),1),AGGREGATE(15,6,$C$1:$C$1000/(($A$1:$A$1000=A2)*($B$1:$B$1000 = AGGREGATE(15,6,$B$1:$B$1000/($A$1:$A$1000=A2),1))),1),1),"")
And for the end date in F2:
=IF(A2<>A1,EOMONTH(DATE(AGGREGATE(14,6,$B$1:$B$1000/($A$1:$A$1000=A2),1),AGGREGATE(14,6,$C$1:$C$1000/(($A$1:$A$1000=A2)*($B$1:$B$1000 = AGGREGATE(14,6,$B$1:$B$1000/($A$1:$A$1000=A2),1))),1),1),0),"")
Then copy down the desired rows.
The aggregate function was introduced in 2010 so it will not work in excel 2007 or earlier.
I over thought they can be simplified to:
=IF(A2<>A1,AGGREGATE(15,6,DATE($B$1:$B$1000,$C$1:$C$1000,1)/($A$1:$A$1000=A2),1),"")
And:
=IF(A2<>A1,AGGREGATE(14,6,EOMONTH(DATE($B$1:$B$1000,$C$1:$C$1000,1),0)/($A$1:$A$1000=A2),1),"")
Thanks to #Jerry for showing a more succinct method.
Here is something that I think should work for any version of Excel, and thanks to the comment from #ScottCarver you can now copy it down and it will put the dates on the first row of each Item:
Enter this in E2 as an array formula and then copy down:
=IF(A2<>A1,MIN(IF(A:A=A2,DATE(B:B,C:C,1))),"")
Enter this in F2 as an array formula and then copy down:
=IF(A2<>A1,MAX(IF(A:A=A2,DATE(B:B,C:C+1,0))),"")
Because these are array formulas you need to press control-shift-enter instead of just enter. After they are entered they will be surrounded by { } to indicate that they are array formulas.
Original Answer:
Here is something that I think should work for any version of Excel, but you can't copy it down - you have to enter one separately for every Item. If you really want them spread out so that the dates are on the row of the first occurance of the Item (like in your screenshot) then this won't really work for you.
For the start date of the Laptop Item:
=MIN(IF(A:A="Laptop",DATE(B:B,C:C,1)))
For the end date of the Laptop Item:
=MAX(IF(A:A="Laptop",DATE(B:B,C:C+1,0)))
These are array formulas so you need to press control-shift-enter instead of just enter. After they are entered they will be surrounded by { } to indicate that they are array formulas.

Using month qualification in SUMIFS statment

Here's what I'm looking for....
Trying to Sum the count of worksheet 'Results 2013' column G items
IF Cell A matches "Canada"
IF Cell E (date) is July
Having trouble with the date portion of the SUMIFS statement below.
SUMIFS('Results 2013'!$G$2:$G$510,'Results 2013'!$A2:$A$510
,"=Canada",'Results 2013'!$E2:$E510,MONTH('Results 2013'!$E2:$E510)=7)
Example value of "Results 2013"$E$480 is
I try this formula, and it provides back "January" which is obviously incorrect.
=TEXT(MONTH('Results 2013'!$E$480),"mmmm")
However, this formula, results in TRUE or 1
=IF(MONTH('Results 2013'!$E$480)=7,1,0)
The simplest solution is to add a column Month using the MONTH function to compute values, and then refer to this new column in SUMIFS.
This tests whether the date values in column E fall within the range 7/1/2013 and 7/31/2013. If your dates all fall within 2013, it will work.
SUMIFS('Results 2013'!$G$2:$G$510,'Results 2013'!$A2:$A$510,"=Canada",
'Results 2013'!$E2:$E510,">="&DATE(2013,7,1),
'Results 2013'!$E2:$E510,"<="&DATE(2013,7,31))
This array formula will work with the more general case of dates falling within any year:
=SUM(G2:G510*(A2:A510="Canada")*(MONTH(E2:E510)=7))
You could use an array formula , then you can use month on the entire column:
{SUM(if('Results 2013'!$A2:$A$510="Canada",1,0)*if(MONTH('Results 2013'!$E2:$E510)=7,'Results 2013'!$G$2:$G$510,0))}
just remember to use ctrl+shift+enter rather than the usual enter to finish the formula

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