I am having trouble writing a formula in Google sheets that will return the previous quarter based on today's date.
For example, if I have cell A1 as =today() which is 1/26/22, I would like cell B1 to return the previous quarter "Q4 2021".
Thanks in advance!
I didn't hear back from you on my comment to your original post. But assuming that you are, in fact, using Google Sheets and that you are actually only needing the return for one cell (A1), this should work in B1:
=VLOOKUP(MONTH(A1),{1,"Q4";4,"Q1";7,"Q2";10,"Q3"},2,TRUE)&" "&YEAR(A1)-IF(MONTH(A1)<4,1,0)
If you were trying to get such a return for an entire columnar range (say, A2:A with a heading in A1), you could use this version in B1:
=ArrayFormula({"Prev. Quarter"; IF(A2:A="",,VLOOKUP(MONTH(A2:A),{1,"Q4";4,"Q1";7,"Q2";10,"Q3"},2,TRUE)&" "&YEAR(A2:A)-IF(MONTH(A2:A)<4,1,0))})
Here you go... just copy and paste this formula in B1:
=IFS(
A1="","",
AND(MONTH(A1)>=1,MONTH(A1)<=3),"Q4 "&YEAR(A1)-1,
AND(MONTH(A1)>=4,MONTH(A1)<=6),"Q1 "&YEAR(A1),
AND(MONTH(A1)>=7,MONTH(A1)<=9),"Q2 "&YEAR(A1),
AND(MONTH(A1)>=10,MONTH(A1)<=12),"Q3 "&YEAR(A1)
)
Related
I'm trying to set some things in my Excel in order to improve my process.
I would like to create a VBA function which let to display value in cell B13 if cell B11 contains "_01_Clients_Particuliers" and cell B12 contains "_00".
These cells are dropdown list.
I never use VBA up to now.
I could write into the cell B13 :
=IF(COUNTIF(B11,"_01_Clients_Particuliers"),"_100PRD05","")
But I need to take into account two cells and I assume I need to use VBA to do that, because the cell B14 has already a formula : =INDIRECT(B13)
Do you have any idea ?
Assuming you drop-down list only contain few selection, then the following formula should be work for you.
=IF(AND(ISNUMBER(SEARCH(H1,C1)),ISNUMBER(SEARCH(H2,C2))),"It is there","not found")
In addition, you will write the range reference directly, it will return error in my case
Unless I've misunderstood your question, I don't think you need VBA to do this.
Check out Using IF with AND, OR and NOT functions
Again, apologies if I'm mistaken, but it seems that your desired result could be produced with the following formula in B13:
IF(AND(B11 = "_01_Clients_Particuliers", B12 = "_00"), "_100PRD05","")
This will put the value "_100PRD05" in B13 if B11 equals "_01_Clients_Particuliers" and B12 equals "_00".
I'm trying to create a cell A7 that changes to the date 2 days prior to date input in another cell A5.
The DateFormula does what you Need:
=DATE(YEAR(A5),MONTH(A5),DAY(A5)-2)
-- leaving this here because still true for VBA --
The DateAdd function is only available in VBA, not as a cellfunction
Put this in A7:
=DateAdd("d", -2, A5)
first Google result
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)))))
Forgive me as I'm a bit of a novice with Excel and have no idea if this is possible or not. Looking for a formula to return one of four values, based on two criteria. One is a Drop-down list with either "Sun-Sat" or "Thur-Wed" options, and the other is a date value. If the date entered falls on a Monday or Tuesday it should return one value, and if the date entered falls on a Wednesday/Thursday/Friday it should return another.
A B
Sun-Sat Thurs-Wed
1 Monday/Tuesday 28/06/2015 25/06/2015
2 Wednesday/Thursday/Friday 5/07/2015 2/07/2015
Drop down box is cell B6 and Date is cell A6
I hope that is enough detail, any help is greatly appreciated!
Say you have these on the "Match" sheet:
A B C
1 Sun-Sat Thurs-Wed
2 Monday/Tuesday 28/06/2015 25/06/2015
3 Wednesday/Thursday/Friday 5/07/2015 2/07/2015
And say you keep the first criterion(Match!$A) in A2 and the second (Match!$1) in B2.
The formula you'll need is:
=INDEX(Match!$1:$1048576;MATCH($A2;Match!$A:$A;0);MATCH($B2;Match!$1:$1;0))
The MATCH() formulae provides the indices that the INDEX() formula uses to identify the output cell.
As pnuts have highlighted I missed that it was one date and one validation.
=INDEX(Match!$1:$1048576;MATCH(IF(OR(WEEKDAY($A6)=2;WEEKDAY($A6)=3);"Monday/Tuesday";"Wednesday/Thursday/Friday");Match!$A:$A;0);MATCH($B6;Match!$1:$1;0))
is an augmented version for when the A column contains dates. Note: I treated the two sets as alternatives, the weekends will be wrongly classified if existent.
Edit not from answerer - layout might be closer to OP's, with formula adjusted to suit (also shows results from various inputs):
I have a new question concerning formulas in Excel. Thing is, I have a sheet, sheet2, containing dates and values. Currently I am using a combination of the index() and match() functions in to fetch different values, according to certain conditions - one being the date, from sheet2 into another sheet, sheet1, .
The data in sheet2, will be updated from time to time wherefore certain dates in the data will obviously "disappear" and of course, yield an error in the index-match formulae, not being able to find the value at hand.
My question is then, if there is an easy way to write the formula so that if the date we try to find from sheet1 is less than the current date, transform current value into constant value. The pseudo code would be something like,
IF date_to_find from sheet1 IN sheet2 > todays_date Then
Set value to constant (do not evaluate formula)
Else
Find value in sheet2 where the dates are matched in both sheet1 and sheet2
End
I know the easiest way might be to just implement the whole thing in VBA, but just wanted to check if anyone had a nicer solution.
Current formula in sheet1 is
'A872 = "2013-05-17"
'F872 is the goal cell (containing formula)
'$A$1:$K$100 contains date in format "yyyy-mm-dd" (given as column)
'$A$2:$K$2 contains currencies (given as row)
'$A$3:$K$3 contains text (also given as row)
IFERROR(INDEX('sheet2'!$A$1:$K$100;MATCH(A872;'sheet2'!$A$1:$A$100;0);_
MATCH(1;('sheet2'!$A$2:$K$2="EUR")*('sheet2'!$A$3:$K$3="Matching text");0));"")
So, if current date is "2013-05-17", the formula evaluates perfectly and returns, say, 400.000. But tomorrow, "2013-05-18", there is no need to change the cell (2013-05-17 value has past), so I would now like to FIX this value, so that the formula doesn't try and find "2013-05-17" in sheet2 no more. I.e. I want cell F872 to just say "400.000", and not "IFERROR(INDEX(...)"
Thanks,
Niklas
You could just wrap your formula in an IF-statement like this:
=IF(A872<TODAY(),[your formula],[constant value])