Attempting to count cells in Excel using multiple criteria - excel

As the title states, I am trying to count across cell ranges on a separate sheet but cant seem to get it to work. Any help would be greatly appreciated.
=COUNTIFS(MONTH(original!A2:A58),"1",original!D2:D58,"=East")

The issue is the Month() part in your formula. I understand your logic, but you'll have to probably add a new column on the Original sheet that has the month formula conversion there, then update the countif to reference it.
COUNTIFS(Original!monthcol, "1", Original!col, "East")
Again, in summary the Month formula can't do the conversion for an entire range of cells in the CountIf. The only other way would require an array formula. Hope this helps.

You cannot use the MONTH function as a form of sub-function in a COUNTIFS function. You need to add an extra level of calculation with something like a SUMPRODUCT function.
=SUMPRODUCT((MONTH(original!A2:A58)=1)*(original!D2:D58="East"))
That should count the instances where the month of the date in the Original worksheet's column A is January and the corresponding row's column D is East.
If you prefer to stay with a COUNTIFS and can keep the dates to a single year, you can provide a start date and end date which will bracket the month of January for a particular year.
=COUNTIFS(Original!A2:A58,">="&DATE(2015,1,1),Original!A2:A58,"<"&DATE(2015,2,1),Original!D2:D58,"East")
The default comparison operator for COUNTIFS is equals. There is no need to type it in.

Related

Counting number of cells based on month of a date

I am trying to count ยจ"the number of stops during each month", and then place them in another table that contain the header as the months (Data Format).
I tried many formulas, in E5:
=COUNTIFS(A:A;"=GRP 1";MONTH(B:B);"=1")
=COUNTIFS(A:A;"=GRP 1";MONTH(B:B);=1)
=COUNTIFS(A:A;"=GRP 1";MONTH(B:B);"MONTH(E4)")
The error message is the following:
Any one has an idea?
Thanks
The criteria_range argument for the COUNTIFS function generally needs to be a range, and not an array. Hence your formula will fail.
You can use a Pivot table.
Drag the Group Number to the rows area
Drag Date of Stop to the Columns area
Drag Date of Stop to the Values area
Format as desired
For a formula solution, you can use SUMPRODUCT. You have to exclude the first row, or add an additional criteria as text entries will result in a #VALUE! error
E5: =SUMPRODUCT(($A$2:$A$200=$D5)*(MONTH($B$2:$B$200)=MONTH(E$4)))
Note that in your results table, the Date row are real dates formatted to show as they appear.
Or, if your data is in a table, you can use structured references.
=SUMPRODUCT((Table1[[Group Number]:[Group Number]]=$D5)*(MONTH(Table1[[Date of Stop]:[Date of Stop]])=MONTH(E$4)))
Edit:
As an exercise, it is possible to use whole column references, as shown in the formula below which tests to ensure that the column B entries are dates.
However, this will significantly increase calculation times, and is rather inefficient. You are much better off avoiding this by:
Excluding Row 1, or
Using a dynamic range reference, or
Using a Table with structured references
=SUMPRODUCT((IF(ISNUMBER(B:B),A:A,0)=$D5)*(MONTH(IF(ISNUMBER(B:B),B:B,0))=MONTH(E$4)))
Since this is an array formula, you need to "confirm" it by holding down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula as observed in the formula bar
New code.
Think we will have to use EDATE for this formula. For cell(E5) try the following.
=COUNTIFS($A:$A,"GRP "&RIGHT($D5,1),$B:$B,">="&E$4,$B:$B,"<"&EDATE(E$4,1))
Basically EDATE allows you to get the same date (e.g 1st of the month) as many months in advance a you need. In this case, we set EDATE to 1 month in advance.

Excel using COUNTIFS Function to create a Punchcard

In my data source I have a column that contains the Dates of occurrences and a Column that contains the Hour of the same occurrences.
With this, the goal is to obtain a punchcard plot (maybe the bubble chart will be the most appropriate)
The intermediate structure has the weekday(Sunday-Saturday) as rows (A2:A8), and the hours (8-22) as Columns (B1:P1), as each column must have the occurrence count for a week day in an hour.
With this said, I tried to use the COUNTIFS function, using the following approach, for the cell B2:
=COUNTIFS(WEEKDAY(RawData!T2:T9852;1);A2;HOUR(RawData!U2:U9852);B1)
However, Excel is not computing the value, finding a problem on the formula, having also tried using the Insert Formula Option.
place the following in B2
=SUMPRODUCT((WEEKDAY($T$2:$T$8,1)=WEEKDAY($A2,1))*(HOUR($U$2:$U$8)=HOUR(B$1)))
you will need to convert the , to match the ; on your system
In your range A2:A8 enter a known date for monday such as 2017/08/20. Then select A2:A8 and apply custom formatting for the number format and set it to ddd. This will display the day of the week in text but keep the value in the cell a number.
Adjust the ranges to suit your data.
Copy the formula to fill in your table.

How can I find number of entries of a particular type within a given time period in Excel? [duplicate]

As the title states, I am trying to count across cell ranges on a separate sheet but cant seem to get it to work. Any help would be greatly appreciated.
=COUNTIFS(MONTH(original!A2:A58),"1",original!D2:D58,"=East")
The issue is the Month() part in your formula. I understand your logic, but you'll have to probably add a new column on the Original sheet that has the month formula conversion there, then update the countif to reference it.
COUNTIFS(Original!monthcol, "1", Original!col, "East")
Again, in summary the Month formula can't do the conversion for an entire range of cells in the CountIf. The only other way would require an array formula. Hope this helps.
You cannot use the MONTH function as a form of sub-function in a COUNTIFS function. You need to add an extra level of calculation with something like a SUMPRODUCT function.
=SUMPRODUCT((MONTH(original!A2:A58)=1)*(original!D2:D58="East"))
That should count the instances where the month of the date in the Original worksheet's column A is January and the corresponding row's column D is East.
If you prefer to stay with a COUNTIFS and can keep the dates to a single year, you can provide a start date and end date which will bracket the month of January for a particular year.
=COUNTIFS(Original!A2:A58,">="&DATE(2015,1,1),Original!A2:A58,"<"&DATE(2015,2,1),Original!D2:D58,"East")
The default comparison operator for COUNTIFS is equals. There is no need to type it in.

Adding new criteria to my formula

I have formula from that, I am getting output, now I wanted to add one more criteria,
=SUM(SUMIF('Data '!$C$2:$C$410,IF(H7=Translation!$A$2:$A$27,Translation!$C$2:$C$27),'Data '!$J$2:$J$410)*COUNTIF(H7,Translation!$A$2:$A$27)*Translation!$E$2:$E$27)
I wanted to show only last 30 days data, date is in Data sheet column number I.
Any suggestion would be great.
To do that you can change the SUMIF to a SUMIFS function and include the date criteria within that SUMIFS, i.e. with dates in column I this will only cover the last 30 days including today
=SUM(SUMIFS('Data '!$J$2:$J$410,'Data '!$C$2:$C$410,IF(H7=Translation!$A$2:$A$27,Translation!$C$2:$C$27),'Data '!$I$2:$I$410,">"&TODAY()-30,'Data '!$I$2:$I$410,"<="&TODAY())*COUNTIF(H7,Translation!$A$2:$A$27)*Translation!$E$2:$E$27)
confirmed with CTRL+SHIFT+ENTER as before
SUMIFS requires Excel 2007 or later

Autopopulate Excel invoice using vlookup

I'd like to auto-populate an invoice in Excel from data I enter into a lesson roster (blank_monthly.xlsx).
Here I fill in the lesson cost under the date each time they come for tuition.
In the invoice sheet I would like to start writing a customer's name into a cell, I'd like the rest of the table to populate with information from the current month's customer roster.
Can I use =vlookup for this to reference the cell I type the client's name into which then pulls all the other information?
If your names are split on the invoice sheet, but not the lesson plan, then you can use VLOOKUP with wildcards as below
Lesson Plan sheet
Invoice sheet
* in the VLOOKUP function will match any characters.
=VLOOKUP("*"&$A2&"*",Sheet2!$A$2:$G$4,2,FALSE)
If your names aren't split then you can just omit the wildcard search, as below.
=VLOOKUP($A2,Sheet2!$A$2:$G$4,2,FALSE)
Currently if no matches are found then the function will return 0. If you just want a blank cell, then you can nest the function in an IF
=IF(VLOOKUP($A2,Sheet2!$A$2:$G$4,2,FALSE)=0,"",VLOOKUP($A2,Sheet2!$A$2:$G$4,2,FALSE))
VLOOKUP documentation is HERE. You should read up on it.
I assume your data sheet will contain 3 columns like: name, date of lesson and number of lessons. You then want to produce a nice report that your illustrated. The short answer is 'Yes', you can use VLOOKUP provided that you only have one row in your datasheet per person per day and you have a column with the concatenation of Name and date. Otherwise, you have to use SUMIFS. I recommend SUMIFS because it would be cleaner formula.
The name is easy to match. Date should handle itself, as long as you don't try to control Excel's magic. Date is stored as a number. The cell formatting makes it look like a date. Concatenate your Month, Day, Year to the proper format and use the DATEVALUE function.
If you have your anchors ($) correct, you should be able to copy and paste the formula. If you don't want to see 0s on your summary report, don't IF in the formula, control it using cell formatting - custom 0;;.
If you are familiar with Table vs Range, use table. Your formula will look nicer and you don't have to worry about extending your range as you acquire more lessons.

Resources