So I'm currently setting up a sheet that records weekly numbers. I'd love to have something that summarizes the totals (money in, loss, etc) by month. So if the week = 4/4/0 this is April (4) and is calculated just by a drop-down of months. Is such a thing possible in Sheets? I don't need the formula just the clue, really.
Update:
I found something similar:
=SUMIFS($N$7:$N$11,$M$7:$M$11,">="&S8,$M$7:$M$11,"<="&EOMONTH(S8,0))
N7:N11 is amount
M7:M11 is date
S8 is the date I'm querying for
The issue I have with that (^^) formula is that it wants me to present the date as D-MONTH-YYYY
but I'd love the date to just be the MONTH
You can set the column to show just the month by setting its format:
and creating a "Custom date & time"
Alternatively, you can use text to represent the months and convert them to number representation using MONTH(S8&1)
Then, you can do some funky way of converting the "month" to "date" using DATE(YEAR, MONTH(S8&1), 1), where "year" is the year you're querying for.
To sum it up, the formula from your question might look something like this:
=SUMIFS($N$7:$N$11, $M$7:$M$11, ">="&DATE(2022, MONTH(S8&1), 1), $M$7:$M$11, "<="&EOMONTH(2022, MONTH(S8&1), 1),0))
Related
I tried using
=INDEX(GOOGLEFINANCE("NASDAQ:MSFT","price",TODAY(), 2),2,2)
And saw that on some days (e.g. 12/6/2021, a Saturday) the function failed to return value. I assume that it is because there was no trading on that day.
Is there a way for me to pick the last value of a stock prior to that day? (e.g. If I calculate on a Saturday or on a Sunday with an American stock I would get Friday's value, Thursday for an Israeli stock etc.)
I am not aware of a way for GOOGLEFINANCE to automatically adjust for no trading days.
One way to do it is to get the "price" data for the last 7 days (to be safe) and then query that data to get the "price" value next to the max date.
This formula works for me:
=INDEX(QUERY(GOOGLEFINANCE("NASDAQ:MSFT","price", TODAY()-7, TODAY()),"select Col1, Col2 order by Col2 desc",1), 2, 2)
You can use the formula below, in the cell that you want the price to be.
=INDEX(GOOGLEFINANCE(A5;"price";$B$2);2;2)
Where A5 contains the stock symbol, like CMI, JNJ, NEE or whatever.
And the B2 contains the following formula:
=if(weekday(B1)=2;B1-3;if(weekday(B1)=1;B1-2;B1-1))
Finally, B1 is just =today().
This will adjust the day for weekdays only. So if it is Saturday, Sunday or Monday, it will give you the price of the stock on Friday.
Basically it will give the last closing price on business days.
Best regards.
I am trying to observe historical trends on customer acquisitions (new and returning) and am looking to use a formula to automate it for me.
Essentially, I am looking to determine the average amount of new customers we acquire on a specific day, specific week, and specific month. For example: what are the average customers we have acquired every Monday for the past 6 months, or what is the average number of customers we acquire the first week of every month?
Solution:
You can use the date operators in your QUERY statement to filter by month, week, or even day of week.
Examples:
every Monday for past 6 months
=query(A1:B, "select avg(B) where datediff(todate(now()),todate(A)) < 180 and dayofweek(A) = 2", 1)
first week of every month
=query(A1:B, "select month(A),avg(B) where day(A) <= 7 group by month(A) offset 1", 1)
You would need to tweak the sample queries to cover your data range and which columns do you need to average and compare.
References:
QUERY()
Query Language Reference | Scalar Functions
I am trying to figure if the following can be done. If there are duplicate names in the B column then it will see if the date and time were within 24 hours of each other in the A column, if so it will highlight the cell yellow.
Currently, the formula I have will only highlight if it was on the same date. Is there a way I can add to the formula to all take into account time? So that if one response is on 5/20/20 at 17:00 and the next duplicate name is at 5/21/20 at 16:00 then the cell would be highlighted.
Here is the formula I am using the just highlights if it is within the same date:
=ARRAYFORMULA(COUNTIFS(B:B, B2, DATEVALUE(A:A), DATEVALUE(A2))>1)
I am not sure if something like this is possible. I am guessing that the formula would have to compare both datevalue and timevalue. Any help would be appreciated.
Instead of DATEVALUE you can use TO_PURE_NUMBER
This will return you the number of days from January 1, 1900 including the fraction for past hours and minutes opposed to DATEVALUE that rounds the value down to an integral day number.
Sample:
This allows you to calculate the real difference time between your timestamp.
For example like this:
=ARRAYFORMULA(or(COUNTIFS(B:B, B2, TO_PURE_NUMBER(A:A), ">"&TO_PURE_NUMBER(A2)-1, TO_PURE_NUMBER(A:A), "<"&TO_PURE_NUMBER(A2))>0,COUNTIFS(B:B, B2, TO_PURE_NUMBER(A:A), "<"&TO_PURE_NUMBER(A2)+1,TO_PURE_NUMBER(A:A), ">"&TO_PURE_NUMBER(A2))>0))
I have a column with month day numbers, so 20 means the 20th of the month.
I want to know how to check if a value in this column, say 20 is more than or less than today's month day.
I would use conditional formatting to color the cell in red if that day had not passed already.
What I tried to do was set a cell with today's date:
=TODAY()
Then based on this calculate if the month day was less than or greater by using this:
=DATEDIF(F2, "MD")
I was hoping this wold return a number which I could then do a compare with but this is wrong and I am not sure if what I want to do is even possible.
I have read through the documentation and Stackoverflow but I cannot find any close examples.
Thank you.
If you want to check the day of the month you need to extract exactly that.
If your date is in Cell A1 and your threshold (20) in A2 the conditional formatting formula to check if the date has not passed yet would then go:
=DAY(A1) < A2
Currently I am able to Query my data by the date in a timestamp but now I want to narrow it down to the hour and the day
=COUNT(QUERY('Form Responses 1'!$A$2:$E, "Select A where A>=date '"&TEXT(B$5,"yyyy-mm-dd")&"' and A <= date '"&TEXT(B$6,"yyyy-mm-dd")&"'")
I am attempting to build a grid of when my responses come in by date and time over the hour
Date ranges have to be dynamic. I need to go look at a sample of data over a week or a sample of data over a year
How can I add a conditional time and day statement to this?
This is what I want to do
Each cell will be it's own query formulaenter image description here
Try this:
=COUNTIFs(ArrayFormula(WEEKDAY(A:A)),"=1",ArrayFormula(hour(A:A)),"=8")
Where a:a is the array containing your timestamps. This example would populate the Monday at 8 am category.