Sumproduct within date range - excel

I'm using this formula to sum some data according to 4 criteria:
=SUMPRODUCT((Data!$A$2:$A$518=Sheet2!A2)*(Data!$D$2:$D$518=Sheet2!$E$1)*(Data!$E$1:$AW$1>=C2)*(Data!$E$1:$AW$1<=D2)*Data!$E$2:$AW$518).
The formula is set up so that the third and fourth criteria are used to identify a date range that is established in cells c2 and d2 of "Sheet 2".
When I evaluate the formula I notice it is not evaluating the date ranges as I would expect. Excel is assigning "TRUE" values to all the dates when executing the (Data!$E$1:$AW$1>=C2) segment and "FALSE" values to all dates when executing the (Data!$E$1:$AW$1<=D2) segment. There are dates in the data ranging from 2017 to 2020 and the current range I'm working with is December 2018 to November 2019, so the range is within the data.
This causing the formula to return 0 as the value.
The other sections of the formula appear to be working as expected.
I've checked my formatting and all relevant cells are formatted as dates.
Are there any other suggestions?
Thank you!

Related

Count if a range of cells contains a certain month

I have a list that contains dates in M/DD/YYYY format.
In another sheet (see first image), i want to be able to calculate how many times a certain month appears in that list.
The formula i thought would work is
=COUNTIFS(*date range sheet&cells*,ISNUMBER(*date range sheet&cells*),*date range sheet&cells*,(MONTH(*date range sheet&cells*)=1))
In this case, the 1 would be for January, 2 for February and so on.
I am using a countifs because i have another if statement already worked out that i need to combine with this one: (*Date range sheet&another column*),"Loss")
Thank you all
With dates in column A, in C1 enter:
=SUMPRODUCT(--(MONTH($A$1:$A$27)=ROW()))
and copy down through C12:
C1 are the January countsC2 are the February countsetc.

Sumif Dates are equal or greater with exception

Hello I am working with a formula that adds a range of cells after comparing dates. For example range A1:A5 has random dates within the year 2017, range B1:B5 each contain the number 10, cell C3 contains the word "OFF". Range A6:A371 begins with 1/1/17 and ends with 12/31/17. I would like a formula that adds the 10 onwards beginning on the date mentioned in A1:A5 but not if it says "OFF" from that date onwards. The formula I have to add them is
=SUMIF(A7,">="&$A$1,$B$1)+SUMIF(A7,">="&$A$2,$B$2)+SUMIF(A7,">="&$A$3,$B$3)+SUMIF(A7,">="&$A$4,$B$4)+SUMIF(A7,">="&$A$5,$B$5)
Is there a better formula and how can I have it not include the date that has "OFF" in column C? I hope I have explained the problem and goal well, if not please ask me to clarify further.
In B6 put:
=SUMIFS($B$1:$B$5,$A$1:$A$5,"<=" & A6,$C$1:$C$5,"<>OFF")
Then copy down the dataset

Formula with IF AND applied to dates

I need column C to return today's date, only if column A and B both have a date in them. So if only one of the columns has a date in it then column C needs to remain blank. Column A already has an IF formula in it to populate it with today's date if another criterion is met.
Checking if a value is a date can be a bit troublesome - Excel will treat the number 1 as 1st January 1900 and will return TRUE if you ask if it's a date.
I found this formula which seems to work fairly well in identify a date:
=OR(CELL("format",A1)={"D1","D2","D3","D4","D5"})
http://www.mrexcel.com/forum/excel-questions/36619-there-%22isdate%22-type-function-excel.html
But, if your cell's formatted as a date but left blank it will still return true.
So, you need to check it's formatted as a date and contains a valid date.
=IF(AND(CELL("format",$A1)="D1",CELL("format",$B1)="D1",$A1>0,$B1>0),TODAY(),"")
This checks that both cells are formatted as d-mmm-yy or dd-mmm-yy and contains a value greater than 0. 1st January 1900 will still be accepted as a date - you may want to change the 0 to 42005 (1st January 2015) or some other value.
If you're not formatting your dates as d-mmm-yy or dd-mmm-yy you'll want to change "D1" for D2, D3, D4 or D5 - look at the help file for the CELL formula for more info.

Conditional formatting between values? Do I need to restructure my spreadsheet?

I would like to format all cells within the range (essentially fill them with color) of start date to end date in each row.
For example, in the picture below, you can see that cells B8 and C8 contain start and end dates, 1/1/2013 and 3/24/2013 respectively. It is formatting correctly, coloring in cells D8:08.
The header cells contain dates formatted as text. For example, cell D3 (the first J), is actually the date 1 January 2013. Similarly, cell E3 (the second J), is actually the date 8 January 2013, cell F3 is 15 January 2013, and cell G3 is January 22 2013. The pattern repeats for each month, only listing the 1st, 8th, 15th, and 22nd of each month.
PROBLEM: I believe I've got it working most of the way, but it seems to not format correctly if the dates fall outside of the dates assigned in the header cells.
For example, if I assign a start and finish date of 5/31/2013, no cells are highlighted. See below image.
I assume that's because I only have up to May 22 2013 in my header cells, but I would like to keep it to four weeks in each month.
Below is the formula I used to format, which I then applied to the whole range D8:AY43, which is essentially the whole task hierarchy.
=(D$3>=$B8)*(D$3<=$C8)
Is there anyway to change this formula to accommodate my issue (cells won't highlight if they fall outside the range of values designated in the month column headers?) Or do I have to restructure my spreadsheet?
Thanks!
An alternative while keeping "4 weeks" per month would be to change the dates in header column to reflect the end of a "week", rather than the start. So instead of January 1, January 8, January 15, etc., use January 5, January 12, January 19, & January 31. You'll need to tweak your formula to account for that change, but it would preserve the structure of your workbook.
Not 100% certain what you're doing (looks like a Gantt chart?) but looks like you're just trying to evaluate whether the date in Column D is between the start and end dates in cols B & C, in which case:
=AND($B8<=D$3,$C8>=D$3)*1
This tests whether the date in D3 falls between the start/end dates defined in columns B & C, and returns "1" if true, and "0" if false.
To put this in conditional formatting, do the rule like:
=AND($B8<=D$3,$C8>=D$3)*1=1
Here is what the rule should look like in the Conditional formatting dialog:

Determine the range numeric scope from column

I am using following SUMIF formula in sheet2:
=SUMIF(sheet1'!B1:B200,D7,'sheet1'!F1:F200)
There is a month in column A such as Jan from A1 to A200 and Feb from A201 to A300. I want to input Jan (Feb or any other) in some cell of sheet2 and then get its range, it is 1 to 200 in this case. Finally, this range will be used in SUMIF formula to get the result.
How can I do this?
=SUMIFS('sheet1'!F1:F200,sheet1'!B1:B200,D7,'sheet1'!A1:A200,"Jan") should work for Jan, or replace the hard coding for the month with a cell reference (E7?)
SUMIFS uses a different sequence from SUMIF (see for example).

Resources