UPDATE - examples clarified
How do I persuade IMPORTXML to grab either the empty <td> elements or a specific attribute three nodes down, if it exists?
--
I'm trying to pull the schedule from the Olympics website into a G Sheet for #reasons. I got as far as IMPORTHTML will not do the thing that I want, and then spent more hours than I care to mention banging my head against IMPORTXML and XPath. This is the closest I've gotten:
=importxml("https://olympics.com/tokyo-2020/en/schedule/","//[#id='schBoxInner']/table/tbody/tr")
This successfully pulls the right row headers, and apparently also all the appropriate <td> column elements into G Sheets, because if I type in the (empty) columns, I get a #REF error.
It seems to me like this should be easy - I want a table of the days events are taking place, and whether or not an event is occurring. for example, the opening ceremonies are on the 23rd (which, because of their wonky table, is column D:
21st
22nd
23rd
24th
Opening ceremonies
TRUE
Basketball
TRUE
The trick is that it's not a TRUE value on that date: It's <a href=blah><img=blah></a>. I just want to include SOMETHING in that cell in G Sheets, because with my previous formulation it displays...nothing.
If it's actually supposed to be this hard, please tell me now.
There's a Wikipedia for the Olympics Calendar # https://en.wikipedia.org/wiki/Template:2020_Summer_Olympics_calendar
You can Just use,
=importhtml("https://en.wikipedia.org/wiki/Template:2020_Summer_Olympics_calendar","table",3)
to get the table. example
Related
I am trying to create a google sheet showing various crypto prices for a few set times (but lets just use BTC-USD for the moment).
The sheet would show
BTCUSD Current Price, Previous Close, Close 5 days ago and Close 31 days ago
I have tried the following but running into the problems described which appear to be reserved for crypto.
There are various ways one can get the current price:
=GOOGLEFINANCE("BTCUSD") will work - so we are ok for current price
=GOOGLEFINANCE("BTCUSD","change") will not work, however it will work for an equity
=GOOGLEFINANCE("AAPL","change") will work
Similarly
=index(IMPORTHTML(CONCATENATE("https://finance.yahoo.com/quote/","AAPL"),"table",1),1,2) will return from table 1 row 1, column 2 from the yahoo finance page for Apple (an equity)
However
=index(IMPORTHTML(CONCATENATE("https://finance.yahoo.com/quote/","BTC-USD"),"table",1),1,2)
does not work even though the page and table layout appear to be the same
I also notice that
=GOOGLEFINANCE("BTCUSD", "price", DATE(2022,1,1), DATE(2022,8,15), "DAILY") will return the price of bitcoin for the date range,
However
=GOOGLEFINANCE("BTCUSD", "price", DATE(a1), DATE(a2), "DAILY")
will not work even if cell a1 and a2 have a copy and paste of the 2022,1,1 and 2022,8,15 in them.
I suspect the second question relates to the fact that the dates in the formula are not in quotes, however if you reference them from a cell excel may inadvertently put them into a quote causing a problem.
This last problem makes it difficult to solve the problem from a different angle ie by referencing cells as the day changes and we refresh the sheet ie we cannot reference a cell which would always be 5 days ago or 31 days ago.
Answer to your first question
With the first formula, =index(IMPORTHTML(CONCATENATE("https://finance.yahoo.com/quote/","AAPL"),"table",1),1,2) it worked for a moment and then stopped working. Then I tested =index(IMPORTHTML(CONCATENATE("https://finance.yahoo.com/quote/","BTC-USD"),"table",1),1,2) and did not work, I even tried =IMPORTHTML("https://finance.yahoo.com/quote/BTC-USD","table") to see if it was importing the table but you get the same error "Resource at url not found".
I did some research and it seems that Yahoo made some changes to their website and this affected some of their web-pages. It's suggested to use another website that is scrape-able by IMPORT functions. This is just an example of what is mentioned about Yahoo Finance and IMPORT functions, there are other communities that are also mentioning issues with doing web scraping to Yahoo Finance.
Answer to your second question
Issue with this formula =GOOGLEFINANCE("BTCUSD", "price", DATE(a1), DATE(a2), "DAILY"), according to documentation:
Inputs to DATE must be numbers - if a string or a reference to a cell containing a string is provided, the #VALUE! error will be returned.
The correct way would be: DATE(2022,1,1) and if you want to refer to a cell you will have to split 2022,1,1 in three different cells and make the reference this way DATE(A2,B2,C2).
I'm building a spreadsheet that automatically gets a row added when I get an application on my form. Here is the link to the sheet. As you can see, the first tab is just a list of applications, with the location they've applied for, and the date. The second tab is a daily count for each location, which is eventually sent out as an email each night. I'd like to include weekly numbers, and maybe even an ongoing weekly comparison. e.g. # of apps today, this week (so far), last week, etc.
I'm no expert with this stuff and it's getting a bit over my head possibly. Any ideas on how to get this done smoothly?? Thanks a ton in advance!
Your problem (like many) is primarily a problem with the organization of your raw data.
On a new tab called MK.Help, I've put the following formula in cell A2:
=ARRAYFORMULA(QUERY(SPLIT(FLATTEN(Applications!A2:A&"|"&Applications!S2:S&"|"&FLOOR(Applications!S2:S-2,7)+2&"|"&Applications!B2:R),"|",0,0),"where Col4 is not null and Col2>="&I2))
Then I made a simple table on the right with some fairly straightforward COUNTIFS() that look like this:
=COUNTIFS($C:$C,H$2,$D:$D,$F3)
The layout of the data vertically is what's making the formulas relatively simple for the summary.
I am attempting to build a live dashboard for our lovely mechanics to see how many services they have completed in a day. The majority of the time it will be used to only show services from a certain mechanic on today's date, however I would like to be able to change the date it shows date for and so would like to be able to grab that criteria from a certain cell in sheet.
My current thinking is that the dashboard would have a formula like this:
=COUNTIFS(
IMPORTRANGE(
"https://docs.google.com/spreadsheets/d/1bx65qPAChwZ8uxwJsMfh-w5uALdKVdnn8x7LXD6J3zs",
"Servicing!A:A"),
D1,
IMPORTRANGE(
"https://docs.google.com/spreadsheets/d/1bx65qPAChwZ8uxwJsMfh-w5uALdKVdnn8x7LXD6J3zs",
"Servicing!C:C"),
C7)
D1 is where i can put in the date. C7 is where the mechanics name is held. My thinking is that this is not working as the data is populated using a google form. This google form records a timestamp in the following way '3/13/2020 12:09:56' Meaning that It will only match this data if the exact same time matches. Is there a way to make it search for ALL records on a date instead of all from a precise time?
Thanks for reading!
I was able to remove the time from the google forms output by adding and extra column and using this formula
=TO_DATE(DATEVALUE(B805))
B805 is filled by the time stamp from the google form
I then made my formula search for the info in the new colum with the above in each cell. It worked! :)
I'm looking for an easy way to account my son's food intake. The trouble is, all of the forms we've used to date are arduous when trying to collect data straight into spreadsheets. So I thought we could use an IFTT/Do button.
A couple problems I need help with:
IFTTT inputs the data as text: how do I use the DATE function to reformat the cell data for each date?
The "button" we're using represents 30 mL of milk but in a single meal he may eat much more - so we're pressing the button multiple times. What array formula can I use to add all formula for each day?
Here's a link to a sample spreadsheet so far. https://docs.google.com/spreadsheets/d/1ds_IvgS5JWuFmsEipk-wUcsfGQVSVD1tXPydDCoT7Xo/edit?usp=sharing
I hope you enjoy this special time.
I would leave column A alone, probably you get no control on that.
But for column B, if you get to, I follow your lead on the condition, but I would want numbers for the results so I can do math on them, so =ARRAYFORMULA(if(A2:A>"0",30,0))
I introduced a column C for Dates and a Column D for times and did the following in C2 to get them:
=arrayformula(if(isblank(A2:A),"",SPLIT(A2:A," at ",false))).
To make these look nice, I formatted the respective columns as dates and times.
In column E I wanted the various dates, so I wrote in E2,
=unique(C2:C)
Then to get the sums per date I had had a really gross QUERY for SUM(B) where C = Date..., and then I saw the comment with the sumif idea. So in F2 you can put the following and drag down as needed:
=sumif(C2:C,E2,B2:B)
and you have your totals by day.
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.