How do I specify a criteria that compares dates in Excel's SUMIFS function? - excel

I'm using Excel 2010, which includes the SUMIFS function. My spreadsheet is in this format:
A B C
Date Amount Category
01/01/2013 $20.00 CatA
01/12/2013 $35.67 CatB
02/04/2013 $16.98 CatA
etc. In another part of the spreadsheet, I have these cells:
X Y
1 CatA_header
2 Jan-13 formula...
3 Feb-13
4 Mar-13
I'd like to place a formula in the cell specified by formula... (in cell Y2) that sums column B for the given category and the given year/month combination. I thought SUMIFS was right for the task, so I tried this formula:
=SUMIFS(B:B, A:A, AND(MONTH(A:A)=MONTH(X2), YEAR(A:A)=YEAR(X2)), C:C, "="&Y1)
However, this returns 0, even though it should return 20 in my contrived example. How can I use the SUMIFS function to perform this task?

Your row numbers seem to be off by 1, e.g., Y0. Also, you can't filter the criteria range like that, I don't think. Here's a SUMPRODUCT that works on rows 2 to 10:
=SUMPRODUCT(($B$2:$B$10)*(MONTH($A$2:$A$10)=MONTH(X2))*(YEAR($A$2:$A$10)=YEAR(X2))*($C$2:$C$10= Y$1))

Related

Summing the result of nested IF statements in one cell

I've got a pretty complex conditional formula that works for each row of a column (sorry, no excel 2016 IFS) and I would like to get the sum of all instances in a range in one formula without having to make all the rows as a middle step.
Done this quite a bit with other stuff, but for some reason I'm stuck on this one.
The formula per cell is:
=IF((IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<1),0,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<2,1,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<5,2,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<13,3,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<34,4,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<91,5,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<245,6,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<666,7,))))))))
I would like to transform it to a formula that sums everything from the range B:B (or B2:B499) in one go.
I tried some SUM and SUMIF(S) stuff and changing B2 to B:B. That doesn't seem to work.
Oh, if someone has a tip to reduce the nested IF formula to something more readable, that's welcome as well. The idea of the formula is to transform counts to classes.
The datasets that are referred to look like this:
Test_Samples:
Reference_Dataset:
The If statements make up a classification as follows:
0= 0
1= 1
2= 2-4
3= 5-12
4= 13-33
5= 34-90
6= 91-244
7= 245-665
8= 666+
Here you see a count of 2 in "Test_samples", and it is labelled "N" in "Reference_dataset", so the result classifies it as "2" (to avoid confusion: if the count was 5 it would be labelled "3" according to the class criteria).
Say if there are 5 instances with result "2" in the range B2:B499, the sum should be 10.
Create a lookup table like this for your "result value < X" to summarize the If statements into a single lookup table:
Test_Samples B Value
0
1
2
5
13
34
91
245
666
In this example, i've put that on the same worksheet that the formula is placed, in cells A1:A10 (header in A1, so data values in A2:A10). Then you can simplify your formula and make it reference the range of your data like this:
=SUM(MATCH(IF(ISNUMBER(Test_Samples!$B$2:$B$499)*(Reference_Dataset!$H$2:$H$499="N"),Test_Samples!$B$2:$B$499,0),$A$2:$A$10)-1)
Note that this is an array formula and as such must be confirmed with CtrlShiftEnter (instead of just Enter).

EXCEL Formula: Multiply SUMIFS outcome with the corresponding row value from a different column

I am trying to use SUMIFS and multiply its output with the a values from the corresponding row. Example:
Example
In This example I will use just 1 criteria for the SUMIFS, but the concept remains the same:
SUMIFS(C2:C5; B2:B5; "=Sum"). This would return 5 + 6 = 11
Now I want to multiple that by the corresponding probability. Meaning 5 * 50% + 6 * 20%: SUMIFS(C2:C5; B2:B5; "=Sum") *
Any idea how to include the probability in the equation?
Thanks!
You can't use SUMIFS for this unless you add a helper column - try using SUMPRODUCT instead
=SUMPRODUCT((B2:B5="Sum")+0;C2:C5;D2:D5)
SUMPRODUCT multiplies all the arrays/ranges and then sums the result, so we can include your value and probability ranges with a conditional array based on "Sum" in the include range
With a helper column you can just use column E to multiply C and D, e.g. this formula in E2 copied down
=C2*D2
and then use SUMIFS like this
=SUMIFS(E2:E5;B2:B5;"Sum")

Sum with dynamic condition

I have an Excel file in which some columns. The Excel is my bank account.
The D column is date, and not just for one day,its the days of a week.
I want to some all columns in that has the same date, and insert it in new cell.ex : for a week i should have 7 sum.
Here is some possible data from the sheet.
date(Column D) Money(Column K) Sum of same date(Column N)
1396/1/1 2300
1396/1/1 1000 3300 // some of the same date
1396/1/2 1200
1396/1/2 320 1550 // some of the same date
It is possible with Excel functions? Does I need a subroutin?
In L2 try,
=IF(ROW()=MATCH(D2, D:D), SUMIFS(K:K, D:D, D2), TEXT(,))
Fill down.
Use this formula:
=IF(D2<>D3,SUMIF(D:D,D2,K:K),"")
Then copy down
Hey you need to work with Sumif or SUMIFS and your Formula should like,
SUMIFS(D2:D10, C2:C10,">="&TODAY()-7, C2:C10,"<="&TODAY())
Or it should be like,
=SUMIFS(D2:D10, C2:C10,">="&A2, C2:C10,"<="&A3)
Or
=SUMIF(D2:D10, C2:C10,">="&TODAY())
NB: Sum Range is D2:D10 & C2:C10 is Criteria range.
In 2nd example A2 & A3 Cells holds Date value.
Suppose your Dates are in Col A & you want to Sum values in Column B, so instead of Sumif you can use this,
C2=SUMPRODUCT(--(MONTH(A$2:A$10)=ROW()-1),--(B$2:B$10))
NB: MONTH function will pull the Month value from A2 and add with corresponding Cell value in B, drag the formula below.

What is the best way to update the match formula to conditionally format?

=MATCH(C$13, 'Vacation - Holiday'!$B:$B, 0)
C13 is the date 01/01/2016.
I am using this formula to conditionally format a cell in a calendar dashboard. It works great but I need the lookup array to be dependent on the name listed in cell B15.
Can I use AND(Match())? I have tried many things and feel so close but so far.
"Meg" is the header of the "B" column on sheet 'Vacation - Holiday'!$B:$B. There are names in columns A - J.
A B C D E F G H
1/1/2016 1/4/2016 1/5/2016 1/6/2016 1/7/2016 1/8/2016
Meg
The formula you want is:
=ISNUMBER(MATCH(C$13,INDEX(Sheet6!$A:$J,0,MATCH($B15,Sheet6!$1:$1,0)),0))

Formula to sum items in a column only if other column has specific value

I have an excel table with 2 columns. First column contains a string such as A,B,C and second column contains numbers. I want to obtain sum of numbers in each row if text of first column for that row is equal to given text.
For example:
A 2
C 3
B 4
A 1
C 3
formula(A) = 3
formula(B) = 4
formula(C) = 6
and so on.
One way to achieve this is via SubTotal option. Follow the example in this link Creating subtotals
Another way to do the same is using sumif function follow this link Sumif function
SUMIFS() is capable of doing this. As is SUMPRODUCT()
In european excel this would look like this. I don't know where your reference is so I am putting it in a cell named Reference.
SUMIFS($B:$B;$A:$A;"="Reference)
If you want a "running" count, then replace the arrays - from $B:$B to B$2:B2 and similar with $A:$A, and copy it down the rows.

Resources