Countifs dynamic date criteria - excel

In a =COUNTIFS formula which I'm using, I am looking for data (specifically the number of granted patents) before and after a date. This date is listed in separate column and the last criteria in my COUNTIFS formula refers to this cell. However if I slide this formula downwards or sideways for my sample, the last criteria is not dynamic and keeps referring to the same cell (in the example: N2). How do I alter formula so that I can drag it downwards and sideways?
The current formula:
=COUNTIFS('1972-06-06 - 1988-01-12'!$E$2:$E$366963,'MA Acquiror Permno Cusip'!E2,'1972-06-06 - 1988-01-12'!$C$2:$C$366963,"<=N2")
I have tried a variant where the last criteria looks like:
"<=" & N2
yet this returns no hits, the previous formula does return hits but is not dynamic.
Thanks in advance for any help.

Just had this exact same problem and it took me an hour to figure out.
Apparently you need a space between the operator ("<") and the date.
"<= " & N2
^Should work. Notice the space after the equals sign.

Related

Vlookup with specific date showing N/A

I am trying to apply vllokup for a specific month of a specific year. My formula works for string lookup value but not works for date. here I attached my effort
First of all VLOOKUP() will not work in this case because VLOOKUP() always lookup values on first column of table then return value from corresponding row from specified column. So, you first column is strings and vlookup do not find dates on first column. Use Index/Match instead.
=INDEX(B3:B5,MATCH(D1,C3:C5,0))
You can also use FILTER() function.
=FILTER(B3:B5,C3:C5=D1)
Query() will also work-
=QUERY(B3:C,"select B where C= date '" & text(D1,"yyyy-mm-dd") & "'")
Vlookup works by searching columns to the left of the searched column. So you should modify your sheet to look like this (if possible) :
However, you should also take into account that the formatting of your cells could be misleading. If your D4cell has the value 1/Jan/2022 and your C6 cell has the value of 2/Jan/2022, then both of them will show as Jan 2022, but your formula will still return N/A because the real values of the cells are different.

Can you define names for dates in Excel to use them in formulas?

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")

COUNTIF cell description matches and within date range

Hi I am after some help with a COUNTIF formula, I want to add 1 to cell
if the 3 criteria are met (see image) =COUNTIF(K4:K20,D2 AND L4:L20,C6 AND M4:M20,B7) i can get the 2 count from =COUNTIF(K4:K20,D2) but the formula does not work with the AND L4:L20,C6 AND M4:M20,B7
Any help would be great
for first, I'd split your B column in two columns FROM and TO. This helps countifs to evaluate if time is after ( >= ) FROM and before (<) TO.
If you are asking what should you write in your C7 formula, this could be something like (according to columns in my screenshot):
=COUNTIFS(G:G,$C$5,H:H,">="&A6,H:H,"<"&B6,F:F,$B$2)
so use ">=" & cell to evaluate if time if after FROM columns; and "<" & cell to evaluate if is before TO column.
I paste this screenshot of I'd solve this problem:
screeshot
and here you have a working example

Right to left offset formula with match

I'm looking to return the start and end dates of a person availability based upon a gantt chart of their hours on a project.
I can at the minute only return the start of their availability, essentially my formula is looking left to right and returning the date of the first "0" cell it meets.
I need the formula to look right to left and return the date of the cell of the last "0" it meets.
Formula currently is:
=IFERROR(OFFSET(B3,(ROW(B3)-2)*-1,MATCH(0,C3:O3,0)),"")
This formula will return the results you're after:
{=INDEX($C$2:$S4,1,MAX(IF($C4:$S4>0,COLUMN($C4:$S4),0)))}
Enter as an array/CSE formula (use Ctrl+Shift+Enter to complete the formula - this will put the curly brackets in).
NB: It will return 00/01/1900 if the last date is greater than 0.
Adding this custom format to the result cells will hide the 00/01/1900: dd/mm/yyyy;;;
I used this to reference to get the answer:
http://www.mrexcel.com/forum/excel-questions/234469-find-last-value-row-greater-than-zero.html
I found the answer by using the formula above and the link provided. My data set was different to the sample one shown. Hence the cell references are different.
=(OFFSET(A3,(ROW(A3)-2)*-1,LOOKUP(9.999999999999E+307,IF(AA3:CP3>0,COLUMN(AA3:CP3)))))

Summing numeric portion of cell when alpha portion of cell is the same

I have a spreadsheet that has columns for dates and the values can be either "1v, .5v, 1p, .5p, 1s, .5s"
I have 3 columns in each row one for each letter "v, p and s". I want to be able to add the total of all cells in the range grouped by letter and then display the sum for each letter in it's respective column (v, p or c).
Here is an example of the sheet:
Name Vacation Personal Sick 1/5/15 1/6/15 1/7/15 1/8/15
Billy 1.5 1 0 .5v 1v 1p
It is the formula that goes in the vacation/personal/sick cell that I just can't figure out.
I went down the array formula route and came up with essentially the same formula as #Sancho.s :-
=SUM(LEFT($E2:$H2,LEN($E2:$H2)-1)*(RIGHT($E2:$H2)="v"))
You could modify it to take account of blanks:-
=SUM(IF($E2:$H2<>"",LEFT($E2:$H2,LEN($E2:$H2)-1)*(RIGHT($E2:$H2)="v")))
Perhaps this would be better, to ignore any mis-formatted cells:-
=SUM(IFERROR(LEFT($E2:$H2,LEN($E2:$H2)-1)*(RIGHT($E2:$H2)="v"),0))
These all have to be put in with Ctrl-Shift-Enter.
Assuming the range you posted starts at A1, use
=SUMPRODUCT((RIGHT($E2:$G2,1)="v")*LEFT($E2:$G2,LEN($E2:$G2)-1))
in B2. Change "v" and the range to use suitably.
Pro:
It is not an array formula. See why this may be important
Con:
I could not make it work with blank cells.
This "array entered" version will also allow blanks
=SUM(IF(RIGHT(E2:G2)="v",SUBSTITUTE(E2:G2,"v","")+0))
confirmed with CTRL+SHIFT+ENTER

Resources