How to pull 1 January 2021 stock price data with google finance - google-sheets

I'm trying to pull 1/1/2021 stock price data with google finance but it gives an error. I can do it for 2020 or any other time but not 2021. Please write if you know how to solve.
=index(GOOGLEFINANCE("AAPL","close",DATE(YEAR(TODAY()),1,1)),2,2)

you can run:
=GOOGLEFINANCE("AAPL", "close", DATE(2020, 12, 1), TODAY())
and see that there is no value for your date as of right now
solution:
wait a day or more
grab it from an alternative source (yahoo finance)

Related

Google sheets formula to sumif within other sheets in the workbook, without writing out the sheet name, instead using reference/contents column?

I have a googlesheet (sheet 1) which looks like this:
contents contains a column with Months
May 2021
June 2021
July 2021
August 2021
September 2021
October 2021
November 2021
December 2021
January 2022
February 2022
March 2022
April 2022
May 2022
June 2022
Each month / cell in column A (sheet 1) all link to another sheet within the workbook containing the data for each month, all data has different rows, so to summarise each month, I want a formula like this:
=sumif(indirect(A4,&"!A:A"),"ProductA",(indirect(A&"!B:B")))
where A4 references January 2021, and this is linked to sheet January 2021, ProductA is in column A of each monthly breakdown (all sheets after sheet 1), and the number of these in column B.
I want to be able to drag this formula down, and have the sheet look for the sum of ProductA across all months, using Column A in sheet 1 to reference the sheet it should look in, i.e. the month.
Does this make any sense?
I can add more info, apologies for the waffle.
Sheet 2 for example contains Month1 data and looks like this:
Category (Ticket) Count Thread Time
prod1 5 22 8395:35:00
prod2 67 5411 644:24:00
prod3 544 55 18283:24:00
prod4 56 546546 97093:52:00
prod5 75 646 38238:11:00
Here is a formula that should work for you:
=arrayformula(sumif(indirect($A2&"!A:A"),C$1,(indirect($A2&"!B:B"))))
You can place this into cell C2, and then copy it down and across.
The issue with your formula was first that you had (indirect(A&"!B:B")), instead of (indirect(A2&"!B:B")).
Secondly, you need to make sure that there's no extra space after your values.
In the above image, you have an extra space after prod3, so when using the SUMIF and trying to match the value, it was not working. If something is resulting in 0 where it shouldn't be, make sure to check that first. I have found that prod4 and prod6 both have the same issue.

How can I calculate today's date ONLY if today is less than or equal to the last day of the current month in Google Sheets?

I would like to express the following expression in Google Sheets:
IF today's date is less than or equal to the last day of the current month (in this case October 2021), THEN output today's date, OTHERWISE output the last day of the month (i.e. October 31, 2021)
I've tried a few different ways but nothing seems to work. Below is my latest attempt, but I get an #ERROR.
=IF(TODAY(<=2021,10,31),TODAY(),DATE(2021,10,31))
Thank you in advance for your help.
You need EOMONTH() function. Try below formula-
=IF(TODAY()<=EOMONTH(TODAY(),0),TODAY(),EOMONTH(TODAY(),0))
Just use =TODAY(). if you are interested in current month.
If you need today's date, but not further then the last day of October, use:
=MIN(TODAY(), DATE(2021, 10, 31))

Google Sheets - autofill per month/year

I created a calendar based on a tutorial I find online to where you just put in the month and year and it will automatically place the days of the month in the right area. However, when I recreated it for some reason it does not fill in certain months.
This is one of the formulas I am using =IF(Day($A3+G8)>1, DAY($A3+G8),"").
When I use it for some reason it would not fill in August for 2021
This is one of the formulas for August =IF(DAY($A66+B71)>1,DAY($A66+B71),"")
It did it for one month in 2022 as well when I put in the month and year.
Please help!
08/29/2021 - Here is a link to my google sheet if that helps:
https://docs.google.com/spreadsheets/d/1Lm8BINPh6h4RuN1S8-0RCprFyf6wS5WwkOQUTuHHBhU/edit#gid=578097574
I wanted it to automatically fill in the dates in the correct day of the week when I change the month and year.
try:
=INDEX(IFNA(VLOOKUP(SEQUENCE(6, 7), {SEQUENCE(DAY(EOMONTH(B3, ))+WEEKDAY(B3, 2), 1, ),
{IFERROR(ROW(INDIRECT("1:"&WEEKDAY(B3, 2)))/0); SEQUENCE(DAY(EOMONTH(B3, )), 1, B3)}}, 2, )))
where B3 contains August 2021

How to Calculate Age from Year Only in Google Sheets

I have the year a car was purchased in column A. For example, 2015. I'm trying to calculate the age of the vehicle comparing the year provided in column A to TODAY() in an arrayformula, like this...
={"Vehicle Age";arrayformula(if(A2:A="",,(datedif(A2:A,today(),"Y"))))}
For some reason, it gives me the number 115 as the result for every cell where a year has been specified. Any idea why? I can't seem to find an answer on this anywhere on the internets.
Thanks for your help!
You are mixing apples and oranges here, so to speak.
Internally, Google Sheets sees all full dates as a number of days from an origin point of December 31, 1899. As such, the year 2015 on its own, in a comparison with a full date will be seen as two-thousand-fifteen days since December 31, 1899 (or July 7, 1905 — which was 115 some-odd years ago, as would be the case with any relatively recent year, because they'll all be interpreted in their raw form by Sheets as a cluster of days from late June to early July of 1905).
Instead, you want to compare the years only, which will mean extracting the year from TODAY(), since A2:A are already year-only numbers:
={"Vehicle Age";arrayformula(if(A2:A="",,year(TODAY())-A2:A))}
However, since any year's car models are actually released the year before, you may want to add a year to your formula:
={"Vehicle Age";arrayformula(if(A2:A="",,year((TODAY())-A2:A)+1))}
Of course, you could also have turned your A2:A years into real dates (e.g., January 1 of each year listed) and then used datedif as well:
={"Vehicle Age";arrayformula(if(A2:A="",,datedif(DATE(A2:A,1,1),today(),"Y")))}
... or with that extra year added ...
={"Vehicle Age";arrayformula(if(A2:A="",,datedif(DATE(A2:A,1,1),today(),"Y")+1))}
={"Vehicle Age";arrayformula(if(A2:A="",,datedif(DATE(A2:A,1,1),today(),"Y")))}
Not working

Sorting by week in Google Analaytics Sheets add on

I just want to run a simple weekly traffic report with the Google Analytics Sheets add on. It does work fine, but I can't seem to figure out how to sort the weeks in chronological order with the jump from 2019 to 2020.
This is how it looks like
Order of the weeks
Does anybody know what Order I need to enter to have the order from week 38 - 53 and then continue with 1,2...?
Include the year as dimension and order by year and by week, like this:
year week
2019 38
2019 39
2019 40
...
2020 1
2020 2
2020 3
For multi year weekly analysis, it's better to just use the corresponding Mondays for any date for your grouping/summing/analysis than it is to use "Week Numbers"
Those mondays can be obtained by using this arrayformula, assuming your dates were in column A (A2:A)
=ARRAYFORMULA(IF(A2:A="",,FLOOR(A2:A+5,7)-5))

Resources