This question already has answers here:
How to SUM duration in Google Sheets?
(5 answers)
Closed 8 months ago.
some time ago I ported an old timesheet to the google-timesheet to be able to share it online and have others modify it but didn't keeped it so I don't remember how I manage to do.
The goal is to compare two timing sheet, today I wanted to edit the sheet to be able add new datas and write timing in separate page sheet which simplify the comparation as I'll just have to import the data from the page and not rewrite it all the time. My issue is that I'm not enable to replicate on my new pages the format. What I would like is to have this exemple working
Cities
Time
Helsinki
2:04.820
Travemünde
4:03.290
Hambourg
0:30.900
Hanovre
2:28.610
Francfort
4:53.470
Mannheim
1:35.170
Strasbourg
2:13.650
Berne
2:25.190
Genève
2:22.620
Lyon
2:24.000
Marseille
3:34.550
Marseille (ferry)
Palerme
2:28.670
Catania
4:07.670
Total
=SUM(above)
so that I can replicate the format on the other pages as I don't understand why it worked before but not now.
mm:ss.000 is the format I would like to have, but atm my format is [h]:mm:ss.000 and it seems that the hour markdown is necesary so I don't really mind if we need to keep the hour.
This is completely possible with google sheets. Enter the data in the format hh:mm:ss.ms, and use sum() (with a range, obv.) to sum the column. Then select the whole colume and apply a custom number format (data-> custom time/date). Using the dropdown to get the parts and typing the separators you can get Minute(1): Seconds(1).Milliseconds(3) which seems to be what you want.
For sheets to recognise the cell entry as a time it needs the hh: part. But you can certainly hide that in the display.
Demo Spreadsheet
If the spreadsheet locale is set to something which uses , for the decimal point, you need to use that instead of . Google could definitely make that a lot clearer. If you have the time you might even want to open a bug report with them, as the examples in their docs don't work when the locale requires a ,.
As a bonus, you can bulk-convert using a formula like =replace(B2; find("."; B2); 1; ",") * 1 (where B2 is the cell to be converted). Drag down, copy and paste the values, and then format if need be.
use:
=ARRAYFORMULA(TEXT(SUM(IFERROR(TIMEVALUE("0:"&B1:B15))); "[m]:ss.000"))
Related
I am writing some formulas that will make up a dashboard that allows for a dynamic look-up of change in waiting times for admission into a hospital. In this case, what I want to do is create a lookback period of 1 month, 3 months, 6 months, and 1 year to see how waiting times have changed during this time at a few locations. It's a bit of a complex issue, but the stripped down data and my example code can be found here (fully shared for editing).
I have successfully gotten the correct formulas for finding 1 month worth of change, but how to apprroach more than 1 month's worth of data eludes me and this is especially problamatic because the date formatting is not standard excel/google sheets data format. As this data will be continously fed into the spreadsheet, I don't think I have the option to modify it either so I think the only option is to come up with some pretty funky formulas that treat months as text. Alternatively, I guess I can also try to make a formula that reformats the text into valid google sheets dates and then use that to make calculations but then while I could probably write that formula, I'd still not know how to get multiple months worth of data processed. Can anyone help take a look at the sheet? (feel free to copy/edit the file if necessary).
try like this:
=QUERY({INDEX(SPLIT(Data!A3:A, "T"),,1), Data!B3:C},
"select avg(Col3)
where Col1 >= "&DATEVALUE(EOMONTH(TODAY(), -4)+1)&"
group by Col2
label avg(Col3)''")
spreadsheet demo
This question already has answers here:
ultimate short custom number formatting - K, M, B, T, etc., Q, D, Googol
(3 answers)
Closed 1 year ago.
I have a spreadsheet full of data that each number represent thousand
For example: 1,745 represent 1,745,000
How can I convert each number (in the same cell) to represent millions so 1.745 will represent 1,745,000?
In MS Excel it can be done with special paste divide by 1000.
What's the equivalent in Google spreadsheet ?
Thanks!
Sheets' concept of thousands and millions is the same as Excel's (not everything else is however). Sheets does not, at the moment, have a direct equivalent of Excel's Paste Special with Operation.
If you want to convert each number representing thousands (in the same cell) to represent millions in Sheets then you will have to have each be divided by 1000. If you want this without helper cells you probably will need to write a script, though you could edit each cell individually or might export to Excel, use their inbuilt code and import back into Sheets, if required there.
if the number is 1,745 you can't change it in the same cell to million equivalent
if the number is 1.745 you can change it in the same cell but only "visually" to million equivalent with custom number formatting:
note1: its only visual change if you keep one eye shut
note2: this applies to the sheet with US locale. if you want to reverse it use some European locale
I have a google sheet to log what I do at work every day.
for example
no filter
I managed to figure out how to filter it by today.
highlight colon -> data -> filter -> date is today
for example:
only today
but I could not figure out how to filter it by the last x number of days
for example:
goal
I guess I will need to make a custom filter, but I have a really hard time figuring out how to make custom filters in google sheet.
Please help me. Thanks in advance.
I solved this in two ways. One with a filter view, and one with a formula you could also use. Both are in my example spreadsheet based on your provided data.
Filter View:
To view my example use the above link and go to the sheet "Filtered". Then apply "Filter recent days" which is a filter I created. I created this filter by filtering column A for the condition "Date is after". I then chose "exact date..." which allows formula input. The formula I used was =TODAY()-4 which simply filters the data for every instance of column A which is after 4 days ago.
Filter formula:
To accomplish this, I left the original data in columns A and B. Then in C5, I entered the formula =FILTER(A3:B,A3:A>TODAY()-4), which uses basically the same method as above. This will produce a separate output next to your original data with only the recent entries.
I also took this a step further by moving the formula down a cell, and then replacing the 4 in the formula with D2. Now you can change the number in D2 to change how many days it displays.
This question already has answers here:
Scraping data to Google Sheets from a website that uses JavaScript
(2 answers)
Closed last month.
I'm trying to import current stock price from yahoo finance. I used a formula from some website and it partially work. I only know how to tell it to look for a specific query and it worked fine for some other data point I need but the price change query changes from
"Fw(500) Pstart(10px) Fz(24px) C($dataRed)"
to
"Fw(500) Pstart(10px) Fz(24px) C($dataGreen)"
depending if the price is up or down for the day.
How do I modify the formula I'm using below to use the "or" operator in this case? so that it will pull the price down whether the stock is up or down for the day. Thanks!
Formula I'm using:
=IMPORTXML("https://finance.yahoo.com/quote/IBM","//span[#class='Fw(500) Pstart(10px) Fz(24px) C($dataRed)']")
I noticed the other answers did not work for me (they may have worked in the past), so I decided to post this solution. Just put the ticker in cell A1 and one or both of the below formulas somewhere else.
Price:
=IFNA(VALUE(IMPORTXML("https://finance.yahoo.com/quote/" & A1, "//*[#class=""D(ib) Mend(20px)""]/span[1]")))
Change:
=IFNA(VALUE(REGEXEXTRACT(IMPORTXML("https://finance.yahoo.com/quote/" & A1,"//*[#class=""D(ib) Mend(20px)""]/span[2]"), "^.*?\s")))
Currently using googlefinance but find it does not update often enough even when updates set to every minute so currently testing if below will allow updates at least with an F5 press within the sheet
This brings in the price and other information (dated 2022/09/27)
=IMPORTXML("https://finance.yahoo.com/quote/SAVA/", "//*[#id=""quote-header-info""]/div[3]/div[1]/div[1]")
If you just want the price: =IFNA(VALUE(IMPORTXML("https://finance.yahoo.com/quote/" & $A1, "//*[#class=""D(ib) Mend(20px)""]/span[1]")))
You could use a more dynamic/generic xpath that doesnt require such specific paths such as this:
This one pulls in both the price and the change:
=ARRAY_CONSTRAIN(transpose(IMPORTXML("https://finance.yahoo.com/quote/IBM:,"//*[#class='Mt(6px)']//span")),1,2)
If you just want the price:
=trim(IMPORTXML("https://finance.yahoo.com/quote/IBM","//*[#class='Mt(6px)']//span"))
If you just want the change:
=IMPORTXML("https://finance.yahoo.com/quote/IBM","//*[#class='Mt(6px)']//span[2]")
Sadly Yahoo Finance changes the XML/HTML structure of its website quite often. The one that works for now is:
=IMPORTXML("https://finance.yahoo.com/quote/IBM/", "//*[#id=""quote-header-info""]/div[3]/div[1]/div/span[1]")
You may always open the HTML structure and use the developer tools to find and copy the X-path.
P.S.1. Though there seem to be a bug and the function can't retrieve data from URLs where there is a dot/point/period "." in the name.
P.S.2. The IMPORTHTML() function can't also fetch the latest price from Yahoo Finance because the information is neither in a table nor a list. You can try the scripts from this page and this page to list all the tables and lists.
My responses are timestamped as soon as anyone submits a survey. I wanted to count those timestamp monthwise.
URL - https://docs.google.com/spreadsheet/ccc?key=0AkpZp6MVqYv1dE5SZjJIODB1WF9nZDR6b1ZJZjFPenc&usp=sharing
I wanted to find out number of positive responses for a particular question (lets say Q1) for a particular month (lets say May)
Column G is not founded out based on the timestamp of Q1, I had asked the user the month, but that's not the correct way to do so, so I have stopped asking the user to enter the month.
First you have to overcome the fact that the timestamp isn't compatible with googles date format. No biggie,... luckily it looks like you have a fixed format ie DD/MM/YYYY. So you can use the LEFT and RIGHT formulas like so =right(left(a2,5),2) This will give you the month in text, ie 05.
Great.
Now for the harder stuff. If you have the newer google spreadsheets, you can simply use countifs to the effect of:
=countifs(arrayformula(right(left(A$2:A,5),2)),"=05",B$2:B,"=Positive")
For each month, replace the "=05" with the the date number you want. You could also make a month lookup chart for all months and questions so that you don't have to modify the formula for each month and quesiton. For this you replace the "=05" with =[cell number containing month number as text] (NOTE: for making a lookup key, you will have to pay close attention to the fact that you are getting TEXT in the formula above vice a number. There is a difference and they are not compatible as-is.)
Let's say you don't have the new google spreadsheets. Then you can use the old sumproduct() and if(). Yes, it is old. See the following:
=sumproduct(arrayformula(if(right(left(A$2:A,5),2)="05",1,0)),arrayformula(if(B$2:B="Positive",1,0)))
Note in both of these, you need to use arrayformula to convert the column with the timestamp into something useable. If you want to make this part easier by removing the parseing functions (LEFT() and RIGHT()) you need to change the timestamp format to be MM/DD/YYYY. Then you can plug in the the MONTH(DATE) formula and it will be done.
Then make a master sheet like so (note my formula has a "'" in it to make it visible for purposes of demonstration, you should remove it.):
Careful inspection might note that the count is wrong. That is because when I imported your timestamps, times like "02/06/2014 ..." were interpreted to mean "February 06" because of google's auto-formatting. In your sheet you will get the correct count using this formula, because of the way your timestamp is auto-populated.
HINT: To make the month a text you need to enter ="05" in the Month column
Please let me know how you make out.