annotated time line - ruby-on-rails

I'm working with google annotated time line graphs: http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html
My question is: I would like to limit the X-axis to show just a range of hours between 5:00 and 21:00. Today I'm showing already per hour but I would like to limit the range and not show 24 hours. Is it possible?

Can't you just set the zoomStartTime and zoomEndTime to configure the part of the x axis that is shown?
Something like the following might do it, ie set the start and end date/times and also turn off the range and zoom functions.
annotatedtimeline.draw(data, {
'displayRangeSelector' : false,
'displayZoomButtons': false,
'zoomStartTime': new Date(2009, 1 ,2),
'zoomEndTime': new Date(2009, 1 ,5)});
Just a thought after looking here.

Related

In Google Sheets, how do I multiply a duration or interval constant? [duplicate]

This question already has answers here:
How to SUM duration in Google Sheets?
(5 answers)
Closed 2 months ago.
This post was edited and submitted for review 2 months ago and failed to reopen the post:
Original close reason(s) were not resolved
I'm making calculations on production cost (in number of resources) and duration.
I have a process that takes 5 minutes. Using the Duration format, I would enter that as 00:05:00.
I want to queue up this process a certain number of times and calculate the total duration. The output should either be something like 16:35:00 or 5 02:15:00. A "d HH.mm.ss" format.
How, in Google Sheets, do I multiply a Duration by an integer to get a total Duration? To be clear, I am not doing a summation of a column of durations. I am taking a duration constant, such as 5 minutes or 25 minutes, and multiplying it by an integer representing the number of times the process will be run, consecutively.
All these attempts resulted in Formula Parse Error:
=(5*00:05:00)
=(112*00:05:00.000)
=(VALUE(C27)*00:05:00)
=MULTIPLY(VALUE(C27),00:05:00.000)
Well, blow me down. I came up with a workaround while I was trying different ways to fail. I assigned 00:05:00 to it's own cell with the Duration format, then referenced that cell in the formula.
I.E. =C27*J7 gives me 9:20:00 when C27 equates to 112 (it's a summation of it's own) and J7 is the cell holding 00:05:00.
Still doesn't give me days when it goes over 24 hours, and I'd rather have the duration value as a constant in the formula, but it's a step forward.
Would something like this work for you?? It's no longer a number, but if it's for expressing the amount in your desired format it may be useful:
=IF(ROUNDDOWN(W2*W3),ROUNDDOWN(W2*W3)&"d "&TEXT(W2*W3-ROUNDDOWN(W2*W3),"hh:mm:ss"),TEXT(W2*W3,"hh:mm:ss"))
Change the cell references, obviously
PS: If you want to have the value as a constant in your formula, you can try to change the cell reference with TIME function within your formula:
In both Excel and Google spreadsheet, DATE are represented in a number start counting from 1899/12/30,
which...
1 is equal to 1 day
1/24 is equal to 1 hour
1/24/60 is equal to 1 minute
1/24/60/60 is equal to 1 second
you can do like:
=TODAY()+1 which gives you tomorrow, or...
=TODAY()+12/24 which gives you "date of today" 12:00:00
and when you are done with the calculations, you can simply use a TEXT() to format the NUMBER back into DATE format, such as:
=TEXT(TODAY()+7 +13/24 +15/24/60,"yyyy-mm-dd hh:mm:ss")
will return the date of a week away from today at 01:15:00 p.m.
This date/time format doesn't requires a full date to work, you can get difference of two time format like this:
=TEXT(1/24/60 - 1/24/60/60,"hh:mm:ss")
since 1/24/60 is 1 min, and 1/24/60/60 is 1 second,
this formula returns 00:00:59, telling you that there is a 59 seconds diff. between 1 min and 1 sec.

Is it possible to get Google Ads metric data on a daily basis within a date range?

I'm trying to display a bar chart that shows the performance of a Google ad between the 1st of March to the 31st of March. Each bar indicates a day in that range.
At the moment my query looks like
SELECT
ad_group_ad.ad.id,
ad_group_ad.ad.name,
metrics.average_cost
FROM
ad_group_ad
WHERE
segments.date
BETWEEN '2021-03-01' AND '2021-03-31' AND ad_group_ad.status = 'ENABLED'
The data I get back are totals within the range. I need the totals of each day within the range. Is there a way to get this information in one request?
I found a segment that segments the data into weekly slices.
SELECT
ad_group_ad.ad.id,
ad_group_ad.ad.name,
metrics.average_cost,
segments.week,
segments.keyword.info.text
FROM
ad_group_ad
WHERE
segments.date
BETWEEN '2021-03-01' AND '2021-03-31' AND ad_group_ad.status = 'ENABLED'
https://developers.google.com/google-ads/api/fields/v6/ad_group_ad#segments.week
segments.day is not documented but I can see on the google ads dashboard you can segment by days if the date range isn't greater than 16 days. I'm going to keep snooping around and see if I can find how that's done.
You just need to add segments.date to your select.

SUM gives me a date instead of a number in Google Sheets

I am writing a few simple formulas for Google Sheets and I've been stuck on this for a little while now. I am trying to get a quick overlook of how many people got added to a sheet in the past week, counting from Saturday, but unfortunately, it's not working.
I have this piece of code to set the date since last Saturday.
=TODAY()-WEEKDAY(TODAY())
This works just fine. The output gives the date as 3/7/2020.
I then have a different row which checks if the recruitment date, which is stated somewhere differently, is bigger or equal to past Saturday. It checks it like this:
=IF(I2>=K2, "1", "0")
This gives an output of either 1 or 0 (1 if it was on Saturday or after Saturday, 0 if not).
Then I went to the main page, where I want to put the SUM. I put the following code:
=SUM('Control Center'!J2:J)
It should just add the 1's that are said earlier, but instead, it gives me the following date: 12/30/1899.
Does anybody know what went wrong? If you need any clarification, feel free to ask.
go to 123 menu and select Automatic or Number:
Take the quotation marks off the 1 and 0 so:
=IF(I2>=K2, 1, 0)

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

Calculate elapsed time using NOW() with conditional formatting

I'm trying to set up a Google Sheet for volunteers at the local dog shelter. The idea is to have an auto-updating spreadsheet that shows at a glance which dogs really need to be walked, in two ways:
conditional formatting the rows with color based on time elapsed:
red if it's been >6 hours since their last walk,
yellow for 3-6 hours, or
green if they were walked <3 hrs ago.
auto-sorting the rows so that the dogs that have gone the longest are always at the top of the list, and when they get walked, they go to the bottom of the list.
Here's where I'm at.
Problem 1: I'm trying to calculate time elapsed by using the NOW() function (which returns the current date and time), minus the time of the last walk. The problem is that if you only enter a time, Google apparently assumes the date is 12/30/1899. So if I put in 8:00 am, and the current time based on NOW() is 4:00 pm, instead of returning 8:00 hours, it calculates the the duration as 10,000,000+ hours that have elapsed since 8:00 am on December 30, 1899 up to the current date and time. (Similar problem discussed here).
If I keep the output cells in the HH:MM format, it'll initially look OK, because it'll just return the HH:MM as 8:00, BUT I can't use that because then the conditional formatting won't work - it's still actually calculating the 10,000,000 hours since 1899. So I can't set duration values for red/green/yellow because all the output values will be slowly increasing every day we get further away from 1899, meaning I would have to reset the ranges daily.
Obviously I could work around this by always including the time and date, but the idea is to have a spreadsheet that is idiot-proof so that any volunteer can use it by just adding the time they walked the dog. It won't work if they have to input the date too.
Problem 2: Assuming I can get the above to work, how can I set it up so the table automatically sorts itself after any change (i.e. when a dog gets walked and the entry gets updated)?
Help?
Please try:
Problem 1
Green is easy, just format all your data that way with standard fill (CF will override this where applicable).
Select A1 and apply a Custom formula is of:
=and($D1<>"",timevalue(now())>$D1+6/24)
with colour Red and Range A:E
Repeat (the order of these two is important):
=and($D1<>"",timevalue(now())>$D1+3/24)
with colour Yellow and Range A:E.
Save rules and close window.
Problem 2
Create a pivot table by selecting ColumnA:E (may have to get rid of some content present low down in the sheet first) and Data > Pivot Table Report..., to Rows Add field Dog name (do not Show totals), to Values Add field Time since last walk and Summarise by:SUM. Name the sheet PT.
In say J2 of your other sheet (not PT) enter:
=query(PT!A:B, "Select * order by B desc ")
May be worth noting that without the day part there might be problems where times span midnight - if you have walkers with insomnia?!
For the autosorting, I found a script elsewhere on stackoverflow and modified it slightly for my purposes:
function onEdit(event){
var sheet = SpreadsheetApp.getActiveSheet();
if(sheet.getName()=='Sheet1'){
var editedCell = sheet.getActiveCell();
var columnToSortBy = 4;
var tableRange = "a2:f91";
if(editedCell.getColumn() == columnToSortBy){
var range = sheet.getRange(tableRange);
range.sort( { column : columnToSortBy, ascending: true } );
}
}
}

Resources