I'm trying to count the number of instances where a date is entered in a column in Excel. I can't seem to construct the right CountIf statement. I'm trying to count the number of times an instance a date is greater than or equal to 1/5/2015.
=COUNTIF(L:L, >="01/05/15")
I see two issues here
Enclose the comparison operator in quotes
Specify the date to compare to as a date not a string
Better yet put the comparison date in a cell (let's say A1). Formula becomes
=COUNTIF(L:L, ">=" & A1)
Formula:
=COUNTIF(L:L, ">=01/05/15")
Related
I hope you are all well.
I have a question. I have a list with many payments listed on column A with dates (format day/month/year) in column B and I would like to use a formula which says something like
IF= A1 = Q2, "pay", "don't pay" , IF= A2 = Q2, "pay", "don't pay"...
Q2 means quarter 2
Could I define names for dates? For example Q2 would be 01/04/2021 - 30/06/2021 so all the dates within that range would be named Q2.
Best regards
You may try anyone of the approaches as explained below, the first one is using ROUNDUP & MONTH Function and the other one is using DEFINED NAMES.
First Approach ---> Using ROUNDUP & MONTH FUNCTION
• Formula used in cell B3
="Q"&ROUNDUP(MONTH(A3)/3,0)
• Formula used in cell C3
=IF("Q"&ROUNDUP(MONTH(A3)/3,0)="Q2","Pay","Don't Pay")
So you can see i have used two columns in the first approach just to make it understandable, therefore just wrap the formula in cell B3 within an IF logic as shown in cell C3 to get the desired output.
Second Approach --> Using DEFINED NAMES & SUMPRODUCT FUNCTION
• Formula used in Defined Names
=ROW(INDIRECT(--TEXT("01-04-2021","dd/mm/yyyy")&":"&--TEXT("30-06-2021","dd/mm/yyyy")))
So you can see I have Defined the Quarter 2 as _Q2 and the reason is a name must either begin with a letter, underscore (_), or backslash (). If a name begins with anything else, Excel will throws an error.
Therefore the formula used in cell D3
=SUMPRODUCT((A3>=_Q2)*(A3<=_Q2))
The above formula creates an array of TRUE's & FALSE's and multiplies to return the corresponding values.
Now the above formula when wrapped within an IF Function it gives us the requisite output as desired,
Formula used in cell E3 (Same it can be done in one cell, to make it understandable i have used two columns)
=IF(SUMPRODUCT((A3>=_Q2)*(A3<=_Q2))=1,"Pay","Don't Pay")
So this is how you can used a Defined names for dates in excel and then use the same within a formula.
This solution does not provide names for dates but it might meet your needs:
Make sure column A is formatted as a date, then use this formula to get the quarter from the month (this array allows you to set Q1 if it is not the same as calendar quarters):
="Q"&CHOOSE(MONTH(A1),1,1,1,2,2,2,3,3,3,4,4,4)
Then test the value of this column:
=if(C1="Q1", "Pay", "Do not Pay")
You could also create a cell at the top of your spreadsheet and name it current_quarter. Then you would type in the current quarter "Q1", "Q2", ... and your formula would be
=if(C1= current_quarter, "Pay", "Do Not Pay")
You are using standard calendar month quarters, so we can get the quarter number easily by dividing and rounding up.
=ROUNDUP(MONTH(A1)/3,0)
You can then use this number in your IF function.
=IF(ROUNDUP(MONTH(A1)/3,0)=2,"Pay","Don't Pay")
I have a COUNTIFS and I want to say "Count if date >= "value in cell B4"
so lets say I have something like
=COUNTIFS(MySheet!C:C,"Y",MySheet!D:D,">=B4")
It obviously does not recognise that it is looking for a date in cell B4 and therefore I get 0 as a result.
What syntax should I use so it recognises that I am looking for anything where the date is greater to the date in cell B4?
Solution
=COUNTIFS(MySheet!C:C,"Y",MySheet!D:D,">="&B4)
Reason
Anything you enclose in quotes ("") is taken as a string literal. So it was looking to see cells whose value was ">=B4", instead of cells whose value was greater than the value in cell B4.
I have a requirement to sum all the cells in a column from a sheet called Raw Data. But only if a few conditions exist.
The value in Raw Data column B matches the value of a offset from the current cell
The Month of the date in Raw Data Column C is less than or equal to H2
The Year of the date in Raw Data Column C is less than or equal to H2
Here is the formula I have assembled thus far:
=SUMIFS('Raw Data'!$D:$D,'Raw Data'!$B:$B,OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),0,-4),MONTH('Raw Data'!$C:$C),<=MONTH($H$2),YEAR('Raw Data'!$C:$C),<=YEAR($H$2))
It could be a simple syntax error, but I don;t think it is. I keep getting a generic "There is a problem with the formula" error.
Can I get some help?
With SUMIFS the range expects a range not an array so MONTH('Raw Data'!$C:$C) and YEAR('Raw Data'!$C:$C) will not work.
Also when the others are expecting a string so you must use quotes and concatenate the criteria: "<=" & value
In this case we want everything less than the 1st of the next month:
"<" & EOMONTH($H$2,0)+1
Use this:
=SUMIFS('Raw Data'!$D:$D,'Raw Data'!$B:$B,OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),0,-4),'Raw Data'!$C:$C,"<" & EOMONTH($H$2,0)+1)
I wish to count the number of dates in a given column. The column has three possible values for a cell. A cell can be blank, have an "x", or have a date. I don't care what the actual date is, I just want to count the number of cells that have a date in them.
Use COUNTIFS()
=COUNTIFS(A:A,">=" & DATE(1900,1,1),A:A,"<=" & DATE(2045,12,31))
You can bracket the dates to what ever you want.
OR
You can do the negative.
If you are possitive the only three values possible are blank,x, and a date then:
=COUNTIFS(A:A,"<>",A:A,"<>x")
Using COUNT, it counts only if the cell value is numeric. The dates are internally numeric.
=COUNT(A:A)
I'm pretty new to Excel, that question is probably easy, but I dont know what to do :-(.
So this is what I have:
Date Numbers
01.09.11 10
01.10.11 20
01.11.11 30
01.12.11 40
Now what I want is in another cell: Get the number of the date, where the date's month is the current month. How do I do this?
Assuming all your dates are strings of the form "dd.mm.yy", you can use the following array formula:
=INDEX(B1:B4,MATCH(9,VALUE(MID(A1:A4,4,2)),0))
where the 9 is the month number you want to look up. Enter this as an array formula by pressing Ctrl+Shift+Enter.
EDIT:
As pointed out in the comments, you want to match the current month, so incorporating #JMax's suggestion works:
=INDEX(B1:B4,MATCH(MONTH(TODAY()),VALUE(MID(A1:A4,4,2)),0))
To clear up any confusion, MID() returns a string, which by itself will not return a match for the number value returned by MONTH(TODAY()). However, if you stick the MID() function inside a VALUE() function, the string returned by MID() will be converted into a number value. E.g., "09" becomes the number 9, "10" becomes the number 10. This allows you to match the number value returned by MONTH(TODAY()).
However, if your dates are entered as dates with format dd.mm.yy in your sheet instead of as strings, then you can use the same strategy but with a different matching term:
=INDEX(B1:B4,MATCH(MONTH(TODAY()),MONTH(A1:A4),0))
Enter this as an array formula.