When making an API call to omniture (site catalyst) , is there any way to use rolling dates - adobe-analytics

i have created a dashboard in klipfolio and only need 52 weeks data to be fetched by the api with respect to current date .. currenlty i m manualy passing date but i want it to use the system date to automaticall fetch data for me
"dateFrom": "2018-01-10",
"dateTo": "2018-02-05",

You can use Klipfolio's date parameters to accomplish this. In your example, you want the last 52 weeks from today so your query for dates could look like this:
"dateFrom": "{date.addWeeks(-52).format()}", "dateTo": "{date.today}",
Alternatively, if you want it to start on first day of the week 52 weeks ago, your query for dates could look like this:
"dateFrom": "{date.addWeeks(-52).startOfWeek.format()}", "dateTo": "{date.today}",
This will create a 52 week rolling window relative to today so you will not have to update your query every week.

Related

Update: How to calculate date and time duration into Days in google shee? (excluding Sunday)

I know it's basic but I'm new to this. I just want to know how can I calculate the days duration of the two dates?
For example, I have my start date and time 11/22/2021 15:20:43 and end date and time 11/23/2021 14:51:29 I want to calculate the total days from start to end date and time.
Also, If start date time column is BLANK, return to count of days including date today.
Thank you
All you need to do is use the following formula: '=(C2-A2)'. This will give you the elapsed time between the two cells and display it as hours. You can take this calculation further by adding dates too. This is useful if you have work shifts that go more than 24 hours or that include two days within a single shift.
Assuming start dates in column A and end dates in column B, you can try
={"Duration in Days"; Arrayformula(if(len(A2:A) * len(B2:B), datedif(A2:A, B2:B, "d"),))}
Change ranges to suit and see if that works?
EXAMPLE
REFERENCES:
DATEDIF
there is a DAYS formula exactly for that purpose:
update:
=INDEX(IFERROR(1/(1/DAYS(
REGEXREPLACE(TO_TEXT(B1:B), "(.|..)[\/\-\.](.|..)[\/\-\.](.+) (.*$)", "$2\/$1\/$3"),
REGEXREPLACE(TO_TEXT(A1:A), "(.|..)[\/\-\.](.|..)[\/\-\.](.+) (.*$)", "$2\/$1\/$3")))))
demo sheet

Getting data from a google sheet for the previous XX days

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())

Set start and end date to current month Google Anaytics API

I'm setting up Google Sheet report using the Google Analytics app to generate a custom report, I've spent days searching for info on the subject all over the web for an answer to set current month for the report.
I can set start and end date with no problem, but I want the automated reports to be able to reset to the current month without me having to update the start and end date every month.
To achieve this, use the below:
For End Date, use
today
or, to make your report upto the previous day:
yesterday
For the start date, use the formula below:
=CONCATENATE(YEAR(today()),"-",
IF(LEN(MONTH(TODAY()))=1,CONCATENATE(0,MONTH(TODAY())),MONTH(TODAY())),
"-01" )
The formula will concatenate the current year, current month, and 01.
Another way to approach this problem is through using EOMONTH, for example to get the first day of this month:
=EOMONTH(today(), -1)+1

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")

rails - group by day as well as hour

I want to create an array of the number of items created each hour, each day.
I'm tracking how people are feeling, so my model is called TrackMood It just has a column called mood and the timestamps.
If I do
TrackMood.where(mood: "good").group("hour(created_at)").count
I get something like
{11=>4, 12=>2, 13=>2, 15=>1}
I've got 2 issues here
1 How do I add the day into this so it doesn't just add the items created yesterday at 11 o'clock to the items added today at 11 o'clock?
2 How do I make sure it says 0 for hours when nothing is created?
1) Instead of grouping on just the hours part of the date you'll need to group part of the date that is relevant i.e. the date up to the hours and not including anything more specific than that. E.g.
TrackMood.where(mood: "good").group("date_format(created_at, '%Y%m%d %H')").count
2) You're always going to get a hash back from this call even if it doesn't find any groups. If you want to check how many groups there are you can call .size or .count on it.
For PostgreSQL you can use date_part
SO-post - Rails & Postgresql: how to group queries by hour?

Resources