Googlesheet formulas for Crypto Coins - google-sheets

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

Related

I'm stuck on how to "match" 2 columns of date and time in Google Sheets

first timer here.
I've been stuck on creating a formula to calculate how many "leads" were created and modified on the same day with the "B2C Lead Name" being a name. I've redacted some numbers and names for obvious reason.
As you can see, row 8 and 9 for both column B and D fall on the same date. And B2C Lead Name is "Boom." On the top right corner, I've tried multiple ways I could think of to count the instances where the lead was created on Aug 30 and was also modified on Aug 30 while the Lead Name is Boom, but I haven't managed to have it work when at least my formula should've shown 3.
For context, I'm creating a report for my sales team and I've been stuck on this thing for 3 weeks, so any help on this would be extremely appreciated. And if it's not too much to ask, please also school me on why using DATEVALUE and trying to "match" those time and date columns as a criterion doesn't work?
Please let me know if you need any more details on this. Thank you!
Here's what I've been staring at for the past 3 weeks, among countless others: =ARRAYFORMULA(COUNTUNIQUEIFS(NMZHImport!$A:$A,NMZHImport!$G:$G,"*"&U30&"*",DATEVALUE(NMZHImport!$B:$B),"="&DATEVALUE(NMZHImport!$D:$D),NMZHImport!$N:$N,"<>Appointment Confirmation"))
Sheet
Please see my comment to your original post.
That said, given the data as I see it, try this untested formula:
=COUNTA(IFERROR(FILTER(A8:A, INT(B8:B)=DATEVALUE("8/30/2022"), INT(B8:B)=INT(D8:D), E8:E="Boom")))
FILTER will form a virtual array of only those entries in A8:A where the day-only date (obtained by INT) in B8:B is equal to your target date, where that date is also equal to the value in D8:D, and where the value in E8:E is "Boom".
IFERROR( ) will return null if there are no matches (which would otherwise be an error).
COUNTA will count the filtered list (if any).
If this does not work as expected, follow my suggestion in the comment I left to your original post and share a link to your sample data in a spreadsheet.

set times with miliseconds in google sheet [duplicate]

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

Trying to COUNTIFS date = this week (sunday-saturday)?

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.

Google Sheet: IMPORTXML from Yahoo Finance [duplicate]

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.

Google Spreadsheets: Sum over multiple criteria constrained by timeframe

Hello Everyone (this is all in Google Spreadsheets),
I'm trying to make a report where I have to sum the product of the number of Apples and Bananas bought respectively within a certain time frame by different people. The price of the goods differs, depending on who is buying them. The people who buy it do so at different times and purchase a different number of items. The formula should be extendable to include additional people in the future.
For details see this Google Spreadsheet.
I would like to get the calculation without needing steps in-between. If it makes any difference, the number of items bought on specific dates are actually in different worksheets, so they're not on the same page as in the example. I named the ranges accordingly (even though I believe/hope it makes little difference in terms of what formula to use).
Finally, if it were possible to use one formula for the total expenditures, instead of the sum over the cells above that would be grand.
I use the DATEVALUE, because otherwise I wouldn't be able to find the first and the last date of the calendar weeks. There is a dedicated DATEVALUE column in every worksheet. (Additionally, I don't have to deal with the intricacies of the date format, which gets me every time.)
I hope I didn't miss an answer to my problem and provided enough information. I can't get my head around it, I am really looking forward to your answers.
Thank you everyone :)
Greg
P.S. A picture of the sheet, if required: Apples, Bananas & €
Credit to Sennsei from the Google Docs Help Forum (Link). I quote:
I won't be surprised if this isn't the best way to go about this, but regardless, here's my take on solving your problem. Result is based on this modified worksheet.
Apples:
=IFERROR(SUM(ARRAYFORMULA(ARRAYFORMULA(VLOOKUP(FILTER('Prices/Amounts'!$J$4:$J,'Prices/Amounts'!$K$4:$K>=B4,'Prices/Amounts'!$K$4:$K<=B5),FILTER('Prices/Amounts'!$J$4:$L,'Prices/Amounts'!$K$4:$K>=B4,'Prices/Amounts'!$K$4:$K<=B5),3,0))*ARRAYFORMULA(VLOOKUP(FILTER('Prices/Amounts'!$J$4:$J,'Prices/Amounts'!$K$4:$K>=B4,'Prices/Amounts'!$K$4:$K<=B5), 'Prices/Amounts'!$B$3:$D,3,0)))),0)
Bananas:
=IFERROR(SUM(ARRAYFORMULA(ARRAYFORMULA(VLOOKUP(FILTER('Prices/Amounts'!$F$4:$F,'Prices/Amounts'!$G$4:$G>=B4,'Prices/Amounts'!$G$4:$G<=B5),FILTER('Prices/Amounts'!$F$4:$H,'Prices/Amounts'!$G$4:$G>=B4,'Prices/Amounts'!$G$4:$G<=B5),3,0))*ARRAYFORMULA(VLOOKUP(FILTER('Prices/Amounts'!$F$4:$F,'Prices/Amounts'!$G$4:$G>=B4,'Prices/Amounts'!$G$4:$G<=B5), 'Prices/Amounts'!$B$3:$D,2,0)))),0)
Expenditure:
=B7+B8
The B4's and B5's refer to the date constraints. Since the formulae contain $ signs to ensure the cells stay the same, the formula can be dragged across to apply to other weeks without having to touch the formulae. As a plus side, these formulae allows a sheet to be infinitely expandable!
Sennsei

Resources