Using WEEKDAY function inside a COUNTIFS - excel

I want to count the times John was in the blue room and it was a thursday. I played with COUNTIFS and WEEKDAY and checked the documentation.
I tried COUNTIFS with two conditions but got errors or 0 as a result.

As #Gary'sStudent said with the column with the day already in place you do not need the WEEKDAY a simple COUNTIFS will work:
=COUNTIFS(B:B,"Thursday",C:C,"John")
If you did not have that column then you would need to revert to the SUMPRODUCT() formula similar to what #Gary'sStudent has:
=SUMPRODUCT((WEEKDAY(A4:A17)="Thursday")*(C4:C17="John"))
Both formulas will work, the main difference is that the COUTNIFS() is not an array formula, and therefore you are able to use full column references without detriment. The SUMPRODUCT, to minimize calc times, one would need to reference only the dataset.

Consider:
=SUMPRODUCT(--(B4:B17="Thursday")*(C4:C17="John"))
You do not need WEEKDAY() because you have a column that specifically defines each day.

Related

Using vlookup and count in the same formula

I am having difficulties combining Vlookup value with count.
As you can see here, CPR is a unique code for every employee and next to it is the type of mistakes that specific employee did.
In this sheet, i want to count the number of mistakes done by that specific employee from the first sheet which mean the code should only count the cells that only contain value.
Thank you.
You can use following formula:
=SUMPRODUCT(($A$1:$A$10=E2)*NOT(ISBLANK($B$1:$B$10)))
I think you want to use Excel's countif function. I don't think vlookup is helpful here.
For example, if you write =countif(G4:G999, 8345) it will count how many times the number 8345 occurs in that range of cells.
You could use:
=COUNTIF(Jan!G:G,Sheet13!D1)
The above formula count how many times the value in Sheet13!D1 appears in Jan!G:G

Excel SUMIF Function with Multiple Criteria for One Range (not SUMIFS)

UPDATE 2
Here is my formula and the resulting error. There are "#DIV/0" results in column J in some of the March data.
END OF UPDATE 2
UPDATE
So as you can, I am trying to sum up column J for each month (those totals will go in column R-W). So I need to the SUMIF function to look at data that begins with a certain date, which I was able to figure out, but also to not include anything in the sum that is an error.
END OF UPDATE
I've looked around for a bit for an answer to this question but what I am finding is people are using SUMIF when they are looking at two different ranges; not what I'm trying to do.
I am trying to do a SUMIFS that looks at ONE range and has multiple criteria.
For example, I have 262,025 rows in this file. I am trying to write a function that does a summation only if the date begins with 2016/03. The problem is, the data I am actually summing contains some "#DIV/0" errors in it.
This is what I was thinking:
SUMIF(E6:E262025, AND("2016/03*", <>"#DIV/0", J6:J262025)
This does not work though.
Basically, I want to sum up column J only if the month is March and I want to exclude any of the values in column J that are "#DIV/0". If this is indeed a SUMIFS function then my apologies. I looked at the syntax for that function and I didn't think that was what I needed. Looking forward to some feedback.
A simple SUMIFS will do:
=SUMIFS(J:J,E:E,"<=3/31/2016",E:E,">=3/1/2016")
It will ignore the errors.
EDIT
Now that you posted a picture it is obvious that your dates are not actually dates but text that look like dates. Then you can use this simple SUMIF:
=SUMIF(E:E,"2016/3*",J:J)
Again it will ignore the error.
Edit #2
If the errors are in the value column then we will need to use an array formula that ignores them:
=SUM(IF(ISNUMBER(SEARCH("2016/03",E6:E262025))*(ISNUMBER(J6:J262025)),J6:J262025))
Being an array formula it must be confirmed with Ctrl-Shift-Enter upon exiting Edit Mode instead of Enter. If done correctly then Excel will put {} around the formula.

Count seperate EXCEL cells if value >0

Background:
This excel is to track the hours someone works and what days. It also needs to track the total days worked in a week.
Requirement:
The 'Total Days' column needs to count the Monday(M) to Sunday (S) columns if they are greater than 0
Previously I had a simple COUNTIF(H6:K6, ">0") or whatever it was, which worked well.
Now the user has added in extra columns for pay and charge rates each day, after the corresponding day, which has thrown the formula off, and the COUNTIF formula wont do the columns separately inside the same formula.
Snippet of excel layout
Also some clarification, In AZ1 for instance I would want it to count H1, K1, N1, etc up to Z1
If anyone could help me work out a formula, that would be great!
COUNTIFS uses AND logic, whereas, you need OR logic. Try something like:
=COUNTIF(A3,">0") + COUNTIF(B3,">0")+...
EDIT: Since that didn't work, this should do the trick:
=COUNTIF(H5,">0")+COUNTIF(K5,">0")+COUNTIF(N5,">0")+COUNTIF(Q5,">0")+COUNTIF(T5,">0")+COUNTIF(W5,">0")+COUNTIF(Z5,">0")
Try using the MOD function to determine the stagger of the columns. SUMPRODUCT and ISNUMBER can take care of the rest.
=SUMPRODUCT(NOT(MOD(COLUMN(H:Z)-8, 3))*ISNUMBER(H6:Z6))

Sumif Amounts Based on Months for Multiple Months

I have excel data in the following format
Date Amount
01-Jan-16 23.94
12-Jan-16 17.96
26-Jan-16 32.92
03-Feb-16 38.90
20-Feb-16 62.27
26-Feb-16 45.89
I would like to sum the amount field for specific months, that is I would like to sum up the amount in January and also in February separately.
This is the code I have tried thus far which I found in a previously asked question (see Excel Formula to SUMIF date falls in particular month).
=SUM(IF(MONTH(A:A)=1,B:B,0))
It works for January but when I change 1 to 2 it returns zero.
=SUM(IF(MONTH(A:A)=2,B:B,0))
Would sumifs work better?
Here are two other ways of doing it:-
=SUMPRODUCT((MONTH(A2:A10)=1)*B2:B10)
and
=SUMIFS(B2:B10,A2:A10,">="&DATE(2016,1,1),A2:A10,"<"&DATE(2016,2,1))
Change as necessary to get totals for other months.
I have put the results next to the original array formula in this screen shot:-
Use specific range rather than full column. You must use the formula as array formula.
=SUM(IF(MONTH($A$2:$A$1000)=1,$B$2:$B$1000,0))
Press CTRL+SHIFT+ENTER to evaluate the formula as array formula.

Excel - Sum column if condition is met by checking other column in same table

I am trying to create spreadsheet to use in a small retail shop.
I have a workbook which contains expenses figures on a sheet and income figure on another sheet.
We can say that the common ground between the both sheets are the month.
I would like to write a function, which will only select those expenses of a specified month.
Something like -
=SUM(IF( Table4[Month]="January", Table4[Amount]))
// I want the sum of all expenses of a given table for only
// those months which are january etc.
I tried using the above, but it failed.
Actually a more refined solution is use the build-in function sumif, this function does exactly what you need, will only sum those expenses of a specified month.
example
=SUMIF(A2:A100,"=January",B2:B100)
This should work, but there is a little trick. After you enter the formula, you need to hold down Ctrl+Shift while you press Enter. When you do, you'll see that the formula bar has curly-braces around your formula. This is called an array formula.
For example, if the Months are in cells A2:A100 and the amounts are in cells B2:B100, your formula would look like {=SUM(If(A2:A100="January",B2:B100))}. You don't actually type the curly-braces though.
You could also do something like =SUM((A2:A100="January")*B2:B100). You'd still need to use the trick to get it to work correctly.
SUMIF didn't worked for me, had to use SUMIFS.
=SUMIFS(TableAmount,TableMonth,"January")
TableAmount is the table to sum the values, TableMonth the table where we search the condition and January, of course, the condition to meet.
Hope this can help someone!

Resources