How to get current weekly closing price of stock in google sheet? - google-sheets

How can I fetch current weekly closing price of a stock in google sheet?
I have tried using the formula GOOGLEFINANCE("GOOG", "price", TODAY(), TODAY(), "WEEKLY").
But its showing no results.

=GOOGLEFINANCE("NASDAQ:GOOGL", "close",TODAY()-60,TODAY(),"WEEKLY")
You can adjust the TODAY()-60 to a start date DATE(2019,1,1) for example:
=GOOGLEFINANCE("NASDAQ:GOOGL", "close",DATE(2019,1,1),TODAY(),"WEEKLY")
or how you'd like to do it. It might update the current week in real time if you use "price" instead of "close", not sure since it's the weekend, and so nothing is ticking or updating right now.
Since it appears you just want a single result of the most recent weeks closing price, try this:
=INDEX(GOOGLEFINANCE("NASDAQ:GOOGL","price",TODAY()-14,TODAY(),"WEEKLY"),3,2)
Improved the integer for the one above, but it could still theoretically break.
Try this instead, as it gives a 30 day range but only selects the result from within 1 week:
=INDEX(QUERY(GOOGLEFINANCE("NASDAQ:GOOGL","price",TODAY()-30,TODAY(),"WEEKLY"),"select Col2 where Col1 < date'"&TEXT(TODAY(),"yyyy-mm-dd")&"' and Col1 > date'"&TEXT(TODAY()-7,"yyyy-mm-dd")&"' limit 1"),2)
Hope that (finally) helps!

Related

Across multiple rows, for each weekday in-between two dates, calculate a value, then sum by week and group by team member's name

I'm working on a team workload tracker to prevent my coworker from being overloaded with work and help them prioritize.
For this task, I must use Google Sheets.
Explanation:
Peter, John and Harry are all team members. They handle user requests all day every day. When they receive a request, they must enter into a table that looks like the "sample data" tab:
the workload (in days) they think they'll need to address it;
the date they'll start working on it;
the date they must finish it by.
End goal:
This is my end goal. I would like to have one row per team member, and one column per week of the year that shows this team member's total weekly workload across all the requests he's handled that week.
Notes:
They can have concurrent requests.
Requests can span multiple workweeks.
They work Monday-Friday.
A request that takes, say, 2 days to complete does not have to be completed in the 2 days that follow its start date (because it might not be urgent). For instance, a 2-day request that a team member decides to do over a period of 10 working days will take them (2/10) = 0.2 workday per day every day for 10 days.
Each member can (but shouldn't) have a weekly workload equal or greater than 5.
What I've done:
I've messed around with Pivot Tables but couldn't get to my end goal.
I've done the day view. I think I shouldn't use a column per day and somehow need to do all the calculation in (array?) formulas to get to the desired end goal, but I can't figure it out.
Any help would be greatly appreciated!
use:
=ARRAYFORMULA(QUERY(IFERROR(SPLIT(FLATTEN(IF(SEQUENCE(1; MAX(E2:E10-D2:D10))<=E2:E10-D2:D10+1;
A2:A10&"×"&WEEKNUM(D2:D10+SEQUENCE(1; MAX(E2:E10-D2:D10); 0); 2)&"×"&
INDEX(SORT(QUERY(QUERY(SPLIT(FLATTEN(IF(SEQUENCE(1; MAX(E2:E10-D2:D10))<=E2:E10-D2:D10+1;
WEEKNUM(D2:D10+SEQUENCE(1; MAX(E2:E10-D2:D10); 0); 2)&"×"&C2:C10&TEXT(D2:D10+SEQUENCE(1;
MAX(E2:E10-D2:D10); 0); "×ddd×")&ROW(D2:D10); )); "×");
"where not Col3 matches '^$|sam.|dim.|53'"; );
"select Col2/count(Col1),Col4 group by Col2,Col4 label Col2/count(Col1)''"); 2; 1);; 1)&
TEXT(D2:D10+SEQUENCE(1; MAX(E2:E10-D2:D10); 0); "×ddd×"); )); "×"));
"select Col1,sum(Col3) where not Col1 matches '53|^$'
and not Col4 matches 'sam.|dim.' group by Col1 pivot Col2"))

Calculate due dates inside query

I have a table consisting of Billed Date & Payment Terms like this. The TODAY cell is just a reference:
I need to use a query to select & identify which one is overdue for over 30 days. I know a solution is to create another column that calculates the Due Date from the Net and selects one that are later than 30 days compared to Today() with this formula:
=QUERY(A2:B3,"SELECT A, B WHERE A <= date '"&TEXT(TODAY()-30,"yyyy-mm-dd")&"'")
I am wondering if it is possible to calculate the Due Date inside the query without having to create a new column for it. Something like
"SELECT A WHERE A + RIGHT(B:B,2) - 30 > 30
Thank you!
You may try something like-
=QUERY(ArrayFormula((A2:A4+INDEX(SPLIT(B2:B4," "),,2))),"where Col1 <= date '"&TEXT(TODAY()-30,"yyyy-mm-dd")&"'")

Google sheets: Is there a way to quickly/easily add a date range to ~300 cells each with different countifs formulas?

I am using the countifs function to add up a lot of different conditions - I need help to simplify the process so that it doesn't require so much manual formatting every time.
Here is a screenshot of a hypothetical spreadsheet. Here is a hypothetical scenario that will help convey my question. Let's say I am working with 3 clients, Macy's, abercrombie, and gap, to fill several open positions. We are reviewing multiple candidates. When I have reviewed them and approved, I select "yes" in the verdict column (E). When they have been processed, I selected yes in the F column. If I do not approve them, I select No in the column. So on and so forth.
So now I'd like to keep track of how many candidates I've approved and processed for each client for each open position. Here is my spreadsheet for that. I have used the countifs function from the previous spreadsheet, called "Review Document" as follows:
Column C, Row 2 - counting sales associate for abercrombie who have been approved and not yet processed:
=COUNTIFS(
'Review Document'!$B:$B,"abercrombie",
'Review Document'!$C:$C, "sales associate",
'Review Document'!$E:$E,"yes",
'Review Document'!$F:$F,"no")
I essentially do this for every single client, for every single role, for both column C and D. Imagine that there are ~300 rows with different companies and roles - The formula text changes every time to count if "position" and "company".
What I would like to do is now find an easy way to automatically apply a date range to all of these cells, without having to manually add a date criterion for every single formula. For example, in the first spreadsheet, there are dates in Feb, Mar, And April. Is there a way to apply a date range on my second spreadsheet so that it only counts the dates I specify? E.G. - apply some date range to ALL cells in that sheet so that it only counts if the date is 2/15/2022-3/31-2022? I would ultimately like to be able to change the date range quickly without having to manually add a date criterion to 300 cells, and then change it every time I want to see the numbers for a different date range. I was tinkering with conditional formatting but I haven't figured it out.
Thanks!
use:
=INDEX(QUERY(QUERY({A2:A, PROPER(B2:C),
IF((E2:E="yes")*(F2:F<>"yes"), 1, 0),
IF((E2:E="yes")*(F2:F= "yes"), 1, 0)},
"select Col2,Col3,sum(Col4),sum(Col5)
where Col1 is not null "&
IF(J1="",," and Col1 >= date '"&TEXT(J1, "yyyy-mm-dd")&"'")&
IF(J2="",," and Col1 <= date '"&TEXT(J2, "yyyy-mm-dd")&"'")&"
group by Col2,Col3"),
"offset 1", ))

3 latest values, but only for a specific user

I am trying to get the average of the 3 latest values, but only for a specific user.
The range of C are the dates, the range of G are the values I am trying to find the average of, and the range of A are the users.
=ArrayFormula(IFERROR(average(query(IF(len('Month Tracker'!$C:$C),{ROW('Month Tracker'!$C:$C),'Month Tracker'!$G:$G},),"Select Col2 where Col2>0 order by Col1 Desc limit 3"))))
This formula works for getting the average of the latest 3 values for all the users. However, I need for it to look through Month Tracker'!$A$2:$A and apply the formula only if the user in Month Tracker'!$A$2:$A matches the user in A2 in the current sheet... finding the average of the latest 3 values for that user only.
Your formula does not really return rows with latest dates. It just returns rows which are at the bottom. It probably just happens so that your latest dates are at the bottom, but formula never actually checks it as long as they are at the bottom.
Another thing, ArrayFormula does not seem needed in this case.
This is what you can use for your current problem:
=IFERROR(AVERAGE(QUERY(IF('Month Tracker'!$C:$C,{'Month Tracker'!$C:$C,'Month Tracker'!$G:$G,'Month Tracker'!$A:$A},),"SELECT Col2 WHERE Col2>0 AND Col3="""&A2&""" ORDER BY Col1 DESC LIMIT 3")))
If you really need, you can wrap it with ArrayFormula.

Need help creating a formula for dynamic average of last 4 weeks expenses

I am looking to create a spreadsheet that my staff fill out, it then gives me a master sheet with all the data, then I import dynamically to my financial spreadsheet telling me the average cost of my client over the last 30 days.
I am looking to create an AVERAGE formula of the last 30 days when Date = Today (Monday) (I want the weekday Monday as that's when staff hand in invoices)
Hope this makes sense, it's really tough!
Here's a video of me explaining my desired outcome
https://www.loom.com/share/3a9cb75052b246d1af2ba2f9ce9180a7
I've followed several guides & can't figure it out.
=ArrayFormula(iferror(query(average(if(today() - weekday(today(),3)-30)))))
I expected $90 average and I just get blank
You could use this formula:
=AVERAGE(VLOOKUP(TODAY()-WEEKDAY(TODAY(),2)+1,A:H,2,FALSE),VLOOKUP(TODAY()-WEEKDAY(TODAY(),2)-6,A:H,2,FALSE),VLOOKUP(TODAY()-WEEKDAY(TODAY(),2)-13,A:H,2,FALSE),VLOOKUP(TODAY()-WEEKDAY(TODAY(),2)-20,A:H,2,FALSE))
To break it down in to its component parts, the AVERAGE is taken from VLOOKUP results:
VLOOKUP(TODAY()-WEEKDAY(TODAY(),2)+1,A:H,2,FALSE)
The VLOOKUP is looking for the last Monday from the current date:
TODAY()-WEEKDAY(TODAY(),2)+1
Then
TODAY()-WEEKDAY(TODAY(),2)-6
and so on...
When using on your sheet, you will have to specify the column you want to reference in your look up, for colunm B (brand1) use: A:H,2,FALSE), for colunm C (brand2) use: A:H,3,FALSE), for colunm d (brand3) use: A:H,4,FALSE) and so on...
=INDEX(QUERY({INDIRECT("A2:D"&ROW()-1)},
"select avg(Col2),avg(Col3),avg(Col4)
where Col1 <= date '"&TEXT(TODAY(), "yyyy-MM-dd")&"'
and Col1 >= date '"&TEXT(TODAY()-30, "yyyy-MM-dd")&"'"), 2, )

Resources