COUNTIFS for dates within last 12 months - excel

I'm trying to count the number of dates in a range that fall within the last 12 months. The formula I have now counts YTD. Anyone know how i can adjust the formula to count the last 12 months?
=COUNTIFS(O19:O500,"*",L19:L500,B7,P19:P500,">43831")

Both of the following formulas work:
=COUNTIFS(O19:O500,"*",L19:L500,B7,P19:P500,">" & Today()-365))
=COUNTIFS(O19:O500,"*",L19:L500,B7,P19:P500,">" & edate(today(),-12))

Related

Combine date range in column A row 3 though 9 and repeat every 7 rows

I have an excel sheet where I need to take an average cost of 7 days. I have two columns, one with a date and the other with a charge. See the attached screenshot for reference and output. The formula I'm using for charges works as expected in column d. I need to find a way to add the date range in column c. Please advise
Date: Need help here - Column c should repeat, and the next cell should have 2022-08-02 and 2022-14-02. The current formula starts on 2022-02-02 if I drag the cell.
Try below formula to google-sheet.
=INDEX(TEXT(A2+SEQUENCE(10,1,0,7),"yyyy-dd-mm") & " " & TEXT(A2+SEQUENCE(10,1,6,7),"yyyy-dd-mm"))
For Excel-365 no need INDEX().
=TEXT(A2+SEQUENCE(10,1,0,7),"yyyy-dd-mm") & " " & TEXT(A2+SEQUENCE(10,1,6,7),"yyyy-dd-mm")

Excel Date Formula + 3 Months

I am looking to have a formula that takes the date that is manually input in a cell (E2) and automatically populates a date in the column next to it (F2) that is + 3 months from the date manually input in (E2).
eg. If (E2) has 03/11/2021 input manually then the formula in (F2) would populate 03/02/2021. image of part of the sheet
Is this what you are looking for?
=DATE(YEAR(A1),MONTH(A1)+X,DAY(A1))
where X = 3
One can use EDATE():
=EDATE(A1,3)
The second criteria is the number of Months to add.
EDATE will go to the number of months then try to equate the day. If the day exceeds the number of days in the target month it returns the last day of the target month.
For example =EDATE(DATE(2021,11,30),3) will return the 28th of February 2021.

Excel COUNTIF "Column D" year equals 2015 and Column L equals "15 or greater"

I am able to count how many cells there are in Column D with year 2015. And I am able to count how many cells there are in Column L that are 15 or greater. However, I'm looking to combine these two formulas but I don't know how.
The formula I use to count the years is:
=SUMPRODUCT(--(TEXT('Sheet1'!D:D,"YYYY")="2015"))
The formula for counting 15 or greater is:
=COUNTIF('Sheet1'!L:L,">=15")
Can someone please provide a way I can combine these two formulas so I can count how many instances there was 15 or greater for the year 2015?
Thanks
COUNTIFS() with an S allows the ability of multiple criteria and you can bracket the dates:
=COUNTIFS('Sheet1'!L:L,">=15",'Sheet1'!D:D, ">=" & DATE(2015,1,1),'Sheet1'!D:D, "<=" & DATE(2015,12,31))
If your dates are actually text strings that look like dates you can do:
=COUNTIFS('Sheet1'!L:L,">=15",'Sheet1'!D:D,"*2015*")

Dynamic starting point of OFFSET and SUM formula

I have the following Excel spreadsheet:
A B C D E F G
1 Year 2015 2016 2017 2018 2019 2020
2 Revenue 5.000 4.000 6.000
3 Years to go back: 2
4 Sum of Periods: 10.000
In Row 1 you can find the years 2015 til 2020 and in Row 2 the corresponding revenue of each year.
In Cell C3 the user should input the number of years to go back and sum up the revenues. For example if the user puts in a 2 Excel goes back 2 years and sums up the revenue of 2017 and 2016 which is 10.000 in the case above. For this I used the following formula:
=SUM(OFFSET($E$2,0,-C3):$E$2)
This formula and the described calculation above work perfectly so far.
However, in 2018 I will have to adjust the starting point of Cell $E$2 in the formula above to Cell $F$2. Ohterwise the year 2018 will be excluded from the calculation.
=SUM(OFFSET($F$2,0,-C3):$F$2)
My question is now how can I avoid this permanent re-adjustment every year?
--> I think the solution should be a formula that identifies the first "non empty" cell within in a Row and then starts counting back the years from this cell. Somehow a combination of the SUM, OFFSET, ROW & COLUMN formula.
You may use this formula:
=SUM(INDIRECT("R2C" & (MATCH(YEAR(TODAY()),$1:$1,0) - $C$3 + 1) & ":R2C" & MATCH(YEAR(TODAY()),$1:$1,0), FALSE))
But be aware I'm assume the current year - $C$3 is within your data range.
Brief explain:
YEAR(TODAY()) - it will return the year of current date, then you don't need to re-adjust every year
MATCH(lookup_value, lookup_array, match_type) - it will find the value matched in first row, and return the index of cell
INDIRECT() - Form the result of match to a R1C1 notation, and convert the text to excel range
A simpler formula could be to use the 4th parameter of OFFSET to set the width and to calculate the starting point of the OFFSET using YEAR(TODAY()0-2016
=SUM(OFFSET($B$2,0,YEAR(TODAY())-$C$1,1,$B$3))
NON VOLATILE OPTION
Well non volatile if it were not for the TODAY() function. Replace TODAY() with a cell containing the starting year as a date. or replace Year(Today()) with a cell reference just containing the year (integer) and then it will be a non volatile option.
=SUM(INDEX($1:$1,MATCH(YEAR(TODAY()),$1:$1,0)):INDEX($1:$1,MATCH(YEAR(TODAY()),$1:$1,0)-($C$3-1))
Volatile functions recalculate every time something on the spreadsheet changes.
Non volatile functions only recalculate when something affecting them changes.
The index function returns the cell address with in the range its looking. for a 2D range you need to give row and column reference. For a 1D range, you only need to give find the position within the range.
Match finds a value within a given range.

Excel- counter for every hour

I have some dates with time in my excel sheet, i was just wondering if there was a day to have a counter for each time it occurred in that hour. For example,
01-Jan-2015 05.04.18
01-Jan-2015 05.55.24
01-Jan-2015 06.01.45
02-Jan-2015 09.11.32
So there is 2 occurrences in the 05 hour of 1st Jan, 1 occurrence in 06 hour etc.
I would count it manually but there are over 10,000 lines.
Any idea how I could use a formula to set a counter, would I use COUNTIF, or concatenate it first?
I’m sorry if this sounds a little bit stupid, I am just a beginner.
Thanks for your help
If you have all the date occurrences in Sheet1, column A. You could have a list of hours in column A of a second sheet (01-Jan-2015 05.00, 01-Jan-2015 06.00, 01-Jan-2015 07.00 etc.). In column B in that sheet you place a COUNTIFS formula which counts all date occurrences between the date and hour in column A and column A + 1 hour:
=COUNTIFS(Sheet1!A:A,">=" & A1,Sheet1!A:A,"<" & A1+(1/24))
See COUNTIFS function for reference.

Resources