Sumif Dates are equal or greater with exception - excel-formula

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

Related

Sumproduct within date range

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!

How to refer to multiple adjacent cells

I have a work sheet in which there are several cells with a specific entry - let's say "A". These are not all in the same rows/columns. After each cell is a date.
I need to count the number of cells containing "A" which also have a specific date in the cell immediately to its right. I've tried combinations of Countifs and Indirect, with no success. How can I achieve this?
This counts the number of times that there is A in column A and 1 in column B
=SUMPRODUCT(($A$1:$A$5="A")*($B$1:$B$5=1))
This outputs in cell D1
Not too difficult.
I have created a sample sheet with 8 rows and 5 columns of data.
See below, the formula in cell C12 counts the number of occurrences where the a cell with a date of October 31, 2017 is directly to the right of a cell that contains the text A.
If you want more info as to how this works, read on:
When searching for cells that contain A, you don't search in the last column of the data (in this case, column E) because it is impossible for a column to the right to have any date in it. This is why a portion of the formula says A1:D8="A" instead of A1:E8="A". This is the same reasoning why we start searching for a date in column B rather than column A in the formula.
You can achieve this with a helper row. Add additional row on top of your Worksheet. In cell "A1" enter formula below.
=COUNTIFS(A2:A2000,"A",B2:B2000,"YourDate")
Drag this formula to the rightmost of where you have data, then simply sum all values returned by formula.

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.

Count the number of individual days in a formatted column

I have two columns, the first is a date column and the second references the first column cell next to and formats it as a day name.
I would now like to count how many Mondays, Tuesdays and so on are in the second column so it looks like the outlined box in the image. I have tried COUNTIF but that doesn't appear to work, presumably because the second column is a formatted value and not text.
How can I achieve what I'm after?
Excel cells
You can achieve that with an array formula. Just enter the following formula:
{=SUM(IF(WEEKDAY($A$1:$A$10)=2,1,0))}
Here is an example to illustrate the above formula:
The above formula assumes (as illustrated in the sample GIF) that you have the range of dates in column A from row 1 through 10. For each weekday you will have to adjust the formula for the correct week-day number: Monday = 2, Tuesday = 3, etc. COUNTIF will not work.
I am going to assume the dates are in column "A" and weekdays in column "B"
for example, cells A1 and B1
If you are having trouble column "B" being number and just displaying it as "Tuesday",
try changing column "B" formula to below instead of changing format to "DDDD"
=TEXT(A1,"DDDD")
This will change Column "B" to a text, and countif function will work

Sum only matched values from two columns

Hello Everyone,
Does anyone know how to sum the Hours from column B (Hours) if column A numbers matched with column E and sum by months.
Example, take February data as an example, since only 3000 & 4000 existed in both column A & column E, that's why I need to sum the hours (20+10=30) from column B by it's month below.
I also attached the example excel sheet below.
https://www.dropbox.com/s/0s51g1i8g6s6e2d/Test.xls?m
Thanks in advance. :-)
You could get complicated with customer functions but if having an extra column (potentially hidden) doesn't matter then this would work:
In cell D2 enter:
=iferror(vlookup($A2,$E$2:$E$20,1,FALSE),"x")
Drag the formula down.
Under each month you can then put:
=sumifs($B$2:$B$16,$C$2:$C$16,B$22,$D$2:$D$16,"<>x")
Drag the formula across
This assumes you can change the month format in either column C or row 22 to be the same, ie. Jan, Feb, Mar or January, February, March etc.
Written on the fly and not tested so excuse any minor errors...
Both answers posted thus far are just fine, but just as an alternative, here's what I would do. Put this formula in cell D2 and drag it down:
=IF(NOT(ISNA(VLOOKUP(A2, $E$2:$E$20, 1, FALSE))), B2, "")
Then if you make a column containing the names of the months, say from G2 to G7 you have February, March, ..., July, you can put this formula into H2 and drag it down:
=SUMIFS($D$2:$D$16, $C$2:$C$16, G2)
That should get what you want.
Put this formula in Cell D2 and drag down:
=IF(NOT(ISERROR(MATCH(A2,$E$2:$E$20,FALSE))),B2,"")
In row 22, change the month names to be the full name, OR in column C, change the month names to abbreviated 3-letter names, this is so we can make use of the SumIf function.
Then, in Cell B23, put this formula and drag it across:
=SUMIF($C$2:$C$16,B22,$D$2:$D$16)
(I put the formula in row 24 to check against the data you already had in Row 23)
Shouldn't be much harder without a helper column. Just make sure you have full month name in row 22 to match column C data then use this formula in B23 copied across
=SUMPRODUCT(SUMIFS($B2:$B16,$C2:$C16,B22,$A2:$A16,$E2:$E20))

Resources