How do I use Google Doc to Get real time Quotes? - google-sheets

So I have been trying built a spreadsheet which tracks multiple Stocks or Bonds , and one I am trying to add is the US 10-year Treasury .
the formula I used is
=importXML("https://www.marketwatch.com/investing/bond/tmubmusd10y?countrycode=bx","/html/body/div[4]/div[2]/div[3]/div/div[2]/h3/bg-quote")
and it keep showing Imported Content is Empty as I am trying to the get the % Yield
I tried some other sites, unfortunately, it seems like this error is very persistent.
How can I make this work?

try:
=IMPORTXML(A1, "//h1[#class='company__name']")
update:
=INDEX(IMPORTXML(B14, "//h3[#class='intraday__price sup--right']"),,2)&"%"

Related

Google Sheets ImportXML on Coinmarketcap.com

I have a google sheet that I use to track crypto positions and I'm using ImportXML to grab the current price of the coin off of coinmarketcap.com. All of them work with the same set of parameters:
URL https://coinmarketcap.com/currencies//
Full XPath: /html/body/div[1]/div[1]/div/div[2]/div/div[1]/div[2]/div/div[2]/div[1]/div/span
Formula:
=IMPORTXML("https://coinmarketcap.com/currencies/the-sandbox/", "/html/body/div[1]/div[1]/div/div[2]/div/div[1]/div[2]/div/div[2]/div[1]/div/span", "en US")
This works for every coin I've tried EXCEPT SAND (https://coinmarketcap.com/currencies/the-sandbox/) and I've no clue why. I have tried pretty much every combination of the path I can think of.
Does anyone have any ideas? I am totally stuck on this one.
try:
=IMPORTXML("https://coinmarketcap.com/currencies/the-sandbox/";
"//div[#class='priceValue ']")
If you want have pure number without $ try this:
=VALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IMPORTXML("https://coinmarketcap.com/currencies/ethereum/"; "//div[#class='priceValue ']") ;"$";"");",";"");".";","))

ImportXML Function on Google Sheets

I'm having a tough time pulling info in on Google Sheets using the ImportXML function. I want to pull in the price of a crypto coin so that I have a real-time feed. The link that I'm hoping to pull from is:
https://www.dextools.io/app/uniswap/pair-explorer/0x40f0e70a7d565985b967bcdb0ba5801994fc2e80
I've tried out a lot of different formulas and keep getting an #N/A or an error. Some of the ones I've tried:
Copy XPATH fully:
=IMPORTXML("https://www.dextools.io/app/uniswap/pair-explorer/0x40f0e70a7d565985b967bcdb0ba5801994fc2e80","/html/body/app-root/div[3]/div/main/app-uniswap/div/app-pairexplorer/app-layout/div/div/div[2]/div[2]/ul/li[2]/span")
Shortened XPATH (also tried deleting the second backslash before 'li' but that didn't work):
=IMPORTXML("https://www.dextools.io/app/uniswap/pair-explorer/0x40f0e70a7d565985b967bcdb0ba5801994fc2e80","//li[2]/span")
Include class:
=IMPORTXML("https://www.dextools.io/app/uniswap/pair-explorer/0x40f0e70a7d565985b967bcdb0ba5801994fc2e80","//li[2]/span[#class='ng-tns-c93-2 ng-star-inserted']")
Does anyone have thoughts? Thanks!
upon disabling JavaScript the site is empty = can't be scraped by Google Sheets by any import formula.
To avoid the problem above, consider using a proper API service that gives you easy access to the data.
For instance you could get Zero price in USD using
=IMPORTDATA("https://cryptoprices.cc/ZERO/")
If you need it in comparison to ETH you could try doing it by hand
=IMPORTDATA("https://cryptoprices.cc/ZERO/")/=IMPORTDATA("https://cryptoprices.cc/ETH/")
Or use a more advanced API such as CoinGecko's
https://www.coingecko.com/en/api

LOOKUP Function won't output correct value

I'm trying to create an Activity tracker for a game. However, I'm trying to use the LOOKUP function to track activity throughout 3 different sheets. However, the LOOKUP function does not seem to be outputting the correct value. LINK: https://docs.google.com/spreadsheets/d/1tdq6oeEFjgxJg6FXvSH2ZmkgRlHaFiD5aycjvezfNvc/edit?usp=sharing
If you look at Activity sheet, E2:E52, you should understand that it's outputting the wrong value(At least based on what I'm reading on the google docs).
I've tried converting this over to one sheet to see if that was the problem, however, it didn't work there either, I tried being more inclusive of the exact letter and number combination and that didn't help either.
I expect it to output the Attacks column for the username based on the Activity1 sheet.
Any help would be greatly appreciated.
PS: I tagged excel as it does the same exact thing on excel, however it gives slightly different values. I'm very confused.
use VLOOKUP instead:
=ARRAYFORMULA(IFERROR(VLOOKUP(D2:D,
{Activity1!C:D; Activity2!C:D; Activity3!C:D}, 2, 0)))

Cell/column/row divider between formula/import result

This is a Google Sheets case, but if you good enough with MS Excel and
know the solution, don't be shy and share it with the community. Your
experience could be relevant to all of us.
Hello over there! I still didn't find any relevant solution in google, so I post my problem here.
I have a sample sheet and I import data via formula to cell via:
=UNIQUE(INDIRECT(C$2&"!"&$O3)
which means import all unique values via formula from Sheet!Range:range
It works fine, and I receive necessary data like:
But I want to see it like this:
with X (1,2,3,etc) row/cell/column spaces between them. I guess that =SPLIT formula should help me with that, but when I use , as a separator, I receive only first value, not the whole array of results that I needed it to.
So is there any way to achieve the result that I show at the picture above via formula or Google Script?
SAMPLE TEST SHEET with EDIT permission here:
https://docs.google.com/spreadsheets/d/1eYeFI8nL39kLNDkcyyjeqV8tc9LwG7P7cn2NzUIB7Wo
=ARRAYFORMULA(SUBSTITUTE(TRANSPOSE(SPLIT(QUERY(
"♂"&UNIQUE(INDIRECT(F$2&"!"&$G2))&"♂♀",,999^99), "♂")), "♀", ""))

Error when applying multiple filters in Google Analytics Spreadsheet Add-on

I am trying to apply 2 filters with Google Analytics Spreadsheet Addon. I want to find the organic session in the specific pagePath. I used semicolon between the 2 filters
="ga:pagePath"&Report!$P9&Report!$G9;ga:medium==organic.
But after entering, I got Formula parse error. return. I couldn't figure out why it doesn't work.
You may try using , instead of ; as seen in this example. Also, from this documentation, to add more than one filter, you need to first think about how you want to filter the data. It's either be an and(;) or an or(,).

Resources