Getting data from a google sheet for the previous XX days - google-sheets

I'm logging calls, emails and meetings using Google sheets. I am trying to get a chart of results based on a number of days in the past, 7, 30, last month, current month, etc. I am able to do exactly what I need to do using a fixed date but I can't figure out how to convert that to a date range.
Here is what is working:
={ARRAYFORMULA({UNIQUE(FILTER(CRM!M2:M2510,CRM!N2:N2510>=VALUE("2018-06-01 00:00:00"),CRM!N2:N2510<=VALUE("2018-08-01 23:59:59"),CRM!M2:M2510<>"")),ARRAYFORMULA(COUNTIF(FILTER(CRM!M2:M2510,CRM!N2:N2510>=VALUE("2018-06-01 00:00:00"),CRM!N2:N2510<=VALUE("2018-08-01 23:59:59")),SUBSTITUTE(SUBSTITUTE(UNIQUE(FILTER(CRM!M2:M2510,CRM!N2:N2510>=VALUE("2018-06-01 00:00:00"),CRM!N2:N2510<=VALUE("2018-08-01 23:59:59"),CRM!M2:M2510<>"")),"*","~*"),"?","~?")))})}
I need to change the value from a fixed date to a number of days in the past. What do I need to change in this formula? I tried using TODAY() -7 but I keep getting an error saying that I am missing brackets. When I use (TODAY()-7) I just get an #ERROR.
How can I change the VALUE("fixed date") to VALUE(TODAY -7)?

If your data looks like "2018-06-01 00:00:00".
Then use this conditions for filter to filter the last 7 days:
Arrayformula(datevalue(left(CRM!N2:N2510),10))>=datevalue(today()-7)
,
Arrayformula(datevalue(left(CRM!N2:N2510),10))<=datevalue(today())

Related

Stop counting after today date passed in Google Sheets

I have a column on Google sheets with different dates, I made a dashboard where you can see the upcoming rows with dates within 5 days away from today. It's a box saying "Starting within 5 days" and shows how many rows starts within 5 days. I made it work, the problem is that once we reached the date and passed it, it keeps counting it.
Let's say a row have a cell with the date 2022-10-20 and today is 2022-10-21, that means it already passed the date, so it should stop counting it. It should only count as "1" if the date set in a cell is within 5 days from todays date.
I hope I was clear enough, I use currently =COUNTIF('Under arbete'!C2:C; "<" & today()+5)
your formula
=COUNTIF('Under arbete'!C2:C; "<" & today()+5)
will work only today. every next day it will be offset by +1 day because TODAY will "recalculate" on a daily basis
you can either feed it today's date like:
=COUNTIF('Under arbete'!C2:C; "<"&"2022-10-20"+5)
or try to freeze today's date like:
=COUNTIF('Under arbete'!C2:C; "<"&LAMBDA(x; x)(TODAY()+5))
update:
=COUNTIFS(Kommande!C2:C; ">="&TODAY();
Kommande!C2:C; "<"&TODAY()+10)
for multiple sheets:
=COUNTIFS({Kommande!C2:C; Sheet2!C2:C}; ">="&TODAY();
{Kommande!C2:C; Sheet2!C2:C}; "<"&TODAY()+10)

Match date in two cells with conditional formatting, +/- 3 days.. Google sheets

I am making a deadline sheet for office.
I have made a conditional format that compares the dates with our "office are closed"-dates provided by our HR-department. If the delivery date match any of the "office closed"-dates in the next column it will be coloured red.
This works fine, but I just noticed one thing. If the date where 1 day before the holidays, and the holidays would be many days a row starting next day, we wouldn't see that and we would probably get big trouble manage Finnish these masters before deadline as we are not at office for a few days.
So, I thought, maybe I could add to the script something that says: "compare the dates in this column with the dates in "Office Closed"-column, if there is a match within a range of 5 days, color it red...?
Is this something I can do?
here is a screenshot of the sheet.
This is the code I use in Conditional Formatting now:
=COUNTIF($L$4:$L$25,H6)>0 which works fine.
Thanks for any help!
/Andreas
Use following formula in CF:
=IF(LEN(A2),SUMPRODUCT((($C$2:$C+3)>=A2)*(($C$2:$C-3)<=A2)))

Google Sheets, increment cell by month

I have a spreadsheet that keeps track of how old accounts are by months.
Is there a way to have Google Sheets auto update a cell on the 1st of each month?
VG: An account is 78 months old and on Sept 1st it turns 79 months. I want to automatically update it on the 1st of the month so I won't have to manually add 1 to every account age cell.
This is for Excel:
If the value is 78 on 25 August 2016 and you want the value to increment of the first of each month, then enter:
=78+MONTH(TODAY())-MONTH(DATEVALUE("8/25/2016"))+12*(YEAR(TODAY())-YEAR(DATEVALUE("8/25/2016")))
Assuming that your dataset does include an account start date in column A, you can calculate how many whole months are between that date and system date today by using:
=DATEDIF(A2,TODAY(),"M")
Tested this in Excel but should work in Google Sheets as well.
You could add another field, and do the calculation from the sheet:
[A1]=<start date>
[A2]=datedif(a1,today(),"M")
Otherwise, you could use a script to do this once a month, but you would need a list of cells somewhere that need to be updated. I would need to see an example of your spreadsheet layout to give you working code.
The process would be to:
set a daily trigger
check for the first of the month
if it is, go and update all the cells
if not, try again tomorrow
This worked out well for me in Google Sheets
DATEDIF("<MY_STARTING_DATE>", today(), "M")
example:
DATEDIF("8/1/2021", today(), "M")

TABLEAU: calc field to get the last value available

I'm using Tableau Desktop, my data are like this:
KPI,date,monthValue
coffee break,01/06/2015,10.50
coffee break,01/07/2015,8.30
and I want to build a table like this
KPI, year(date), last value
coffee time, 2015, 8.30
How can I set a calculated field in order to show me the last value available in that year? I tried to do:
LOOKUP([MonthValue], LAST())
But it didn't work and tells me 'cannot mix aggregate and non-aggregate', so I did:
LOOKUP(sum([MonthValue]), LAST())
But it didn't work too. How should I proceed?
If you are using Tableau 9 then you can do this with an LOD calc that looks for the max value in your date field and then checks if the current date value is the same as the max date value.
[Date] == {fixed: max([Date])}
As you can see in the example below when you use the calc as a filter you will only get the last row from your example above.
UPDATE: to get the values per year you can do something like:
Here I am using a table calculation to find the max date per year and then ranking those dates and filtering down to the latest date in each year (which will be the one that has a rank equal to 1).
!max date is WINDOW_MAX(ATTR(Date))
!rank is RANK(Date)
You need to make sure that the table calculations are computer in the correct way (in this case across the values of each year).

reformating now() function so it works in GoogleFinance function

I'm using GoogleFinance function in Google spreadsheets to display a chart over the last 5 years. I'm using it as follows:
=GoogleFinance(A1;"all";Date(2012,02,08);Date(2013,02,11); "weekly")
This works fine. However, I have to increment the two dates each day if I want the chart to be up to date. I want to change the above so that it automatically updates each day and always shows a chart of the last 5 years. I tried using the now() function like so
=GoogleFinance(A1;"all";Date(2012,02,08);Date(now()); "weekly")
but it seems now() returns the Date in format d/MM/yyyy instead of the required yyyy,MM,dd format.
I also tried.
=GoogleFinance(A1;"all";Date(2012,02,08);Date(Text(Now(), "yyyy,MM,dd")); "weekly")
This did not work either.
Ideally I need something like the following:
=GoogleFinance(A1;"all";Date(now()-5years);Date(now()); "weekly")
The above does not work, how can I change it so my 5 year chart is always up to date.
I have now managed to work out how to fix my problem.
I used the today() function to solve it as follows
=GoogleFinance(A1;"all";TEXT(TODAY()-YEAR(5);""); TEXT(TODAY();""); "weekly")
A1 contains the stock in my case it was GOOG
I can generate the data to create a 5 year chart of any stock now just by changing the value in A1.

Resources