Count cells if two criteria - but sumproduct didnt work (Excel - excel

I need help with this, please:
I have a table with lot of data and I need count rows where is specific name and specific time (for example John 7:15, Tom 7:00, Nick 8:00 and I need know how many times in table is John beetven 7:00-08:00 and so on...)
countif(s), sumproducts didnt working for me :(
Thanks

First, select your entire times Column and make sure it is all in hh:mm:ss (hours, minutes, seconds) format.
In Column C, set up a Countifs function, with:
The first criteria range being Column A (names)
The first criteria being the name you are looking for, in quotes
The second criteria range being Column B (times)
The second criteria being ">(insert minimum hh:mm:ss value here)"
The third criteria range being Column B (times)
The third criteria being "<(insert maximum hh:mm:ss value here)"

If you can create extra columns, then you may want to try this. I assume the times may have minutes, so that you may have "nick" in cell C2 and "8:15" in cell D2. You want to know how many Nicks there are between 8 and 9? Then in cell E2, extract the hour from the time with "=HOUR(D2)".
Then use COUNTIFS to handle multiple criteria. Let's say you put "Nick" in cell A1 and the number 8 in cell A2, for 8am. Then in cell A3 you could write "=COUNTIFS(C2:C5,A1,E2:E5,A2)" .
I like countifs (with an s) better than countif because it handles multiple criteria better.
Hope this helps.

Column A:
John
John
John
John
John
Tom
Nick
Nick
Nick
Nick
Nick
Nick
Nick
Tom
Tom
Column B:
7:15
8:15
9:15
7:15
7:15
7:00
8:00
9:00
10:00
11:00
12:00
13:00
14:00
7:00
8:00
Formula in C2 cell:
=COUNTIF(A:A,A2)
Formula in D2 cell:
=COUNTIFS(A:A,A2,B:B,B2)

Related

Returning Min date based on criteria ignoring blank dates

I'm trying to return the Min date based on criteria.
A
B
C
D
E
F
Frank
01/01/2014
Susan
Susan
01/01/2018
Min
08/01/2010
Susan
12/01/2021
Max
12/01/2021
Susan
Susan
08/01/2010
The following formula works fine in cell F2 as long as there are no blanks in the date column B. If there are any blanks it returns 01/0/1900
=MIN(IF(A:A=E1,B:B))
I found this solution that ignores blanks but returns the Min date from the entire column, not based on any criteria.
=MIN(IF(B:B=0,"",B:B))
Thank you for the lucid and easily reproducible question. This should do the trick for you:
=MINIFS(B:B, A:A, E1, B:B, "<>")
It ensures that empty date cells corresponding to the given name are not considered.

Excel Sum If based on month of date range?

I have sheet with a list of users and their holidays taken like so:
Katie 1 01/01/2016
Dave 2 12/02/2016
Dave 2 12/12/2015
Katie 1 17/11/20165
Liam 1 05/01/2016
Marie 1 09/08/2015
Marie 5 23/09/2015
I am then using the following SUMIF formula on my other sheet to return the total number of holidays taken for each person
=SUMIF(Data!A$1:A$1000,A13,Data!B$1:B$1000)
This gives me a result like so:
Katie 2
Dave 4
Liam 1
Marie 6
However, now I want to turn my SUMIF into a SUMIFS which only returns the values for the month of January like so:
Katie 1
Liam 1
I know I can get the month of the date by using =TEXT('Cell Ref',"mmmm") but I'm not sure how I would combine this into an SUMIFS statement.
Can someone please show me how I can do this?
Thanks in advance
You would need to use an Array Formula:
=SUM(IF((Data!A$1:A$1000=A13)*(Month(Data!C$1:C$1000) = 1),Data!B$1:B$1000))
Since it is an Array formula it needs to be confirmed with Ctrl-Shift-Enter when leaving edit mode. Then copied down.

Frequency of data occurence in Excel Column based on the certain condition

I have a column (Table 1 below) with time data in 24 hour format saved as text.I want Table 2 to be populated by the hour and adding all the occurrences for the hour.
So one occurrence is at 0102. This falls within an hor range of 12:30am to 01:30pm. I want the count to be 1 for 01:00.
If an occurrence falls between 01:30 to 02:30 I want the count to be 1 for 02:00.
Also if time is 04:55 it should show count for 05:00 as 1. Basically rounding to the closest time and showing a count for that. It should round of to the nearest time and add the number of occurrences also. Thats why 06:00 is 2. to account for 0622 and 0614.
For example:
TABLE 1 TABLE2 (Expected results)
Column A Column A Column B
0102 01:00 1
0222 02:00 2
0223 03:00 0
0455 04:00 0
0622 05:00 1
0614 06:00 2
NOTE In B1 we get 1 because value in A1 of TABLE1 is 0102 and falls between 12:30 and 01:30, thus represented by 01:00 in A1 in TABLE 2. We have two values in Table1 between 01:30 and 02:30: one is in A2 and the second is in A3, so we expect 2 in B2 in TABLE 2, the time range which is represented by 02:00 in A2. We attribute 0 to cells B3 and B4 in Table2 because there isn't any data in Table1 between 02:30-03:30 and 03:30-04:30, therefore they get 0 in their corresponding cells in Table2. However, we have two instances of data, 0622 and 0612 in Table1 which fall between 05:30 and 06:30, so value 2 is attributed to B6.
How do I do this using a formula?
Please help.
So after struggling to understand what was going on, here is the simple solution:
first let me clarify again:
column A: but pasted as text originally and in hhmm format, but you need to reformat them as simple numbers, so you will lose those 0 s at the beginning of certain data.
column B: we put down our time ranges, as you said, starting from 12:30 AM, so i put it down as 0030 of which the zeros are not visible anymore in number format. This range starts from 30 and increments by 100, until it stops at 2330 instead of going to 2430. this will be reflected in the formula for the last cell in column D.
column C: the hour ranges against which we round and count the data in A.
column D: we put down the following formula in D2 :
=COUNTIFS(A:A,">"&$B2,A:A,"<"&$B3)
and drag and fill down until the last but one cell.
for the last cell D25 we change the greater/smaller than signs, and use the following formula (only for this cell):
=COUNTIFS(A:A,"<"&$B25,A:A,"<"&$B2)
Try these formulas, if it doesn't work, download the example sheet,
here is the example sheet i created for this purpose, downloadable from here
and if you still have questions, don't hesitate to put them in the commentaries.

Count if date range fits within other date range

I have a set of data with names of people who are on vacation for certain dates (Name, Start, End).
Example:
Name Start End
Joe 10-Jan-14 21-Jan-14
Billy 12-Feb-14 10-Mar-14
David 11-Jan-14 20-Jan-14
Patty 10-Jan-14 19-Jan-14
Megan 05-Jan-14 20-Jan-14
-------------------------------
Block 15-Jan-14 22-Jan-14
I want to count the number of people in the range who are going to be on vacation during the block dates. It should return 4; Joe, David, Patty and Megan.
The formula I have is:
=COUNTIFS(colStart, ">="&B1, colEnd, "<="&B2)
colStart and colEnd are named ranges of the Start and End column.
B1 and B2 are the block dates on my spreadsheet.
My problem is that it won't count someone who started before the block start date or ends after the block end date.. even though they will be on vacation during some point in the block dates. Joe, for example.. starts on 10 Jan. He will be on vacation still during the block dates.
Visually I am comparing number lines. I just need help to translate that to code.
Just turn your formula round a little.
If the start date is equal to or earlier than B2 AND the end date is greater than or equal to B1 then there must be some sort of overlap of the periods - if one or other of those conditions doesn't hold then there is no overlap, hence this formula gives your count
=COUNTIFS(colStart,"<="&B2,colEnd,">="&B1)
Here's how to view it from the opposite side of Jerry's answer. You have two scenarios that you don't want.
Start date after your block
End date before your block
Count all the dates and exclude those two.
=COUNT(colStart)-SUMPRODUCT((colStart>blkEnd)+(colEnd<blkStart))
Let's assume Start date reference is on B1 and End date reference is on B2.
Also, consider that the dataset header starts on cell A4 (Name) and first row of data is #5.
Type on D5 (and drag the formula down):
=IF(OR(AND(B5>$B$1,B5<$B$2),AND(C5>$B$1,C5<$B$2),AND(B5<$B$1,C5>$B$2)),1,0)
Then, in any cell:
=SUM(D5:D9)

Countifs to match OR conditions?

I have the following countifs formula
=COUNTIFS($F$2:$F$848,Summary!$F5,'Report'!$G$2:$G$848,$Q$10,$G$2:$G$848,$Q$11)
on my sheet, Q10 = Monday, Q11 = Tuesday
On 'Report', G2:G848 contains login data
Objective: I need the total count from Report that are either on Monday(Q10) or Tuesday (Q11)
With the current formula I have, countifs is looking for rows that has Monday and Tuesday in the row, which is a wrong.
How can I solve this ?
Presumably F2:F848 is also on Report sheet? Try this
=SUMPRODUCT(COUNTIFS('Report'!$F$2:$F$848,Summary!$F5,'Report'!$G$2:$G$848,$Q$10:$Q$11))
Assumes formula resides on same sheet as the Q10 and Q11 values....
The COUNTIFS function will return an "array" of 2 values, one for Monday (Q10) and one for Tuesday(Q11), then SUMPRODUCT just sums the 2 values to give you the total for both days
=COUNTIF('Report'!$G$2:$G$848,"Q10")+COUNTIF('Report'!$G$2:$G$848,"Q11")
This assumes that 'Report'!$G$2:$G$848 contains the Q10 and Q11 values you're talking about.

Resources