I have an issue with the IMPORTXML function and then changing the currency in my portfolio tracker.
IMPORTXML (C3=IMPORTXML(B3,"//div[#class='priceValue___11gHJ']") takes the price of a cryptocurrency from coinmarketcap (B3=https://coinmarketcap.com/currencies/ethereum/ - this all works fine (would rather prefer to have the prices from coingecko, but cannot figure the IMPORTXML function for that website... - if anyone has some valuable input for this too, would be great).
However, the imported price in C3 has a dollar sign before the actual numbers, which mess up the GOOGLEFINANCE formulas in columns D (D3=C3GoogleFinance("CURRENCY:USDEUR")) and E (E3=C3GoogleFinance("CURRENCY:USDGBP")). Screenshot of the error attached. Error Message
Does anyone know how to fix this?
Much appreciated!
Rob
On cell C3 you could use:
=VALUE(SUBSTITUTE(IMPORTXML(B3,"//div[#class='priceValue___11gHJ']"),"$",""))
References:
SUBSTITUTE
VALUE
If I understand correctly, the problem is that the imported price in C3 has a dollar sign in front of the actual numbers, which breaks down further processing by formulas.
To solve the problem, you can wrap the formula in C3 in a MID() formula that returns a segment of a string. If we specify a position number equal to 2, starting from which the string segment will be extracted, then the dollar sign at position 1 will be ignored. The sign of the pound or the euro will also be ignored - any currency sign with a length of 1 symbol.
10 is the segment length with some margin. Please note if the end of string is reached before segment length characters are encountered, MID returns the characters from starting position to the end of string.
C3:
=MID(IMPORTXML(B3,"//div[#class='priceValue___11gHJ']"),2,10)
MID()
Here's a little workaround to import the prices from coingecko, and remove the $ simbol, of course:
=SUBSTITUTE(IMPORTXML("https://www.coingecko.com/en/coins/ethereum"; "//div[contains(#data-controller,'coins-information')]//span[contains(#data-coin-symbol,'eth')]");"$";"")
But, as you can imagine, if they change the html structure of the site, this will stop working.
Have fun!
Related
emails
vera#mail.com
estebangarrido#mail.c
hurtado#mail com
jmariano2mail.com
How can I pass a fuction which correct all domains to #mail.com. I know I have to use =RIGHT(,9) but when you reach the last error it does not apply
Try below formula-
=ArrayFormula(IF(A2:A="",,QUERY(SPLIT(SUBSTITUTE(SUBSTITUTE(A2:A,"mail","|"),"#",""),"|"),"select Col1",0)&"#mail.com"))
This should also work.
=INDEX(IF(LEN(A2:A),QUERY(SPLIT(SUBSTITUTE(SUBSTITUTE(A2:A,"mail","|"),"#",""),"|"),"select Col1")&"#mail.com",""))
Answer
The following formula should produce the results you desire. It assumes that the data you provide is in cells A2:A5 of your spreadsheet. If this is not the case, adjust the A2:A5 portion of the formula appropriately.
=ARRAYFORMULA(REGEXREPLACE(A2:A5,"[#|2].*","#mail.com"))
Explanation
This formula uses REGEXREPLACE to get rid of all rogue characters and replace them with #mail.com. The first argument of REGEXREPLACE is the string to be evaluated. In this case, that is the range from A2 through A5. The second argument is which characters to look for. In this case that is all characters (done using .*) that follow either an at-sign or a numeral two (done using [#|2]). The third argument is which new string to replace the found characters with. In this case that is #mail.com, the correct domain without typos.
The REGEXREPLACE is wrapped in =ARRAYFORMULA because normally REGEXREPLACE can only be used with a single cell rather than a range of cells.
Please note that this solution relies on the assumption you stated that "Everything before # or 2 is correct."
Is there anywhere where I can find the list google uses when you a-z sort a list with a filter?
EDIT: Image for clarity:
More specifically, I need a character that is discreet; ideally a blank character; that is sorted after the plus sign '+'.
I've made a test. You may see the result in Sample File:
I tried first 3000 chars:
Column A: numbers from 1 to 3000
Column B: char formula: =CHAR(A2)
I sorted the range with filter and got an unexpected result: Google is not using ASCII to sort text.
Also, see sort function works the same way as sort by a filter. But sorting with query gives another result.
When I tried the same experiment in Excel I was confused even more:
=CHAR(A2) gives another result in Excel, it not an ASCII char
sorting range of chars gives different from Sheets result. Please try it yourself to see.
Using google spreadsheets to display currency data, with USD as primary field for formula: =LEFT(V10*GoogleFinance("currency:USDEUR"),5)
I cannot figure out how to remove the the USD Symbol ($) from not show up for the additional currencies. It makes no sense to have the **$**xxx being displayed on non-USD data.
I have tried doing Format -> Numbers but none of those options resolve this issue.
The number formats are not working since the LEFT function is converting the value to text. Does this formula work instead:
=SUBSTITUTE(LEFT(V10*GoogleFinance("currency:USDEUR"),5),"$","")
Highlight the cells you want to change. Go to Format --> Number --> More Formats --> Custom number format. Highlight the "$" and delete it (delete the quotes and dollar sign both). Click apply. I have attached before and after pictures.
I did some searching and in openoffice and excel it looks like you can simply add an * at the beginning or end of a character to delete everything before and after it, but in Google spreadsheet this isn't working. Does it support this feature? So if I have:
keyword USD 0078945jg .12 N N 5748 8
And I want to remove USD and everything after it what do I use? I have tried:
USD* and (USD*) with regular expressions checked
But it doesn't work. Any ideas?
The * quantifier just needs to be applied to a dot (.) which will match any character.
To clarify: the * wildcard used in certain spreadsheet functions (eg COUNTIF) has a different usage to the * quantifier used in regular expressions.
In addition to options that would be available in Excel (LEFT + FIND) pointed out by pnuts, you can use a variety of regex tools available in Google Sheets for text searching / manipulation
For example, RegexReplace:
=REGEXREPLACE(A1,"(.*)USD.*","$1")
(.*) <- capture group () with zero or more * of any character .
USD.* <- exact match on USD followed by zero or more * of any character .
$1 <- replace with match in first capture group
Please try:
and also have a look at.
For spaces within keyword I suggest a helper column with a formula such as:
=left(A1,find("USD",A1)-1)
copied down to suit. The formula could be converted to values and the raw data (assumed to be in ColumnA) then deleted, if desired.
To add to the answers here, you can get into trouble when there are special characters in the text (I have been struggling with this for years).
You can put a frontslash \ in front of special characters such as ?, + or . to escape them. But I still got stuck when there were further special characters in the text. I finally figured it out after reading find and replace in google sheets with regex.
Example: I want to remove the number, period and space from the beginning of a question like this: 1. What is your name?
Go to Edit → Find and replace
In the Find field, enter the following: .+\. (note: this includes a space at the end).
Note: In the Find and replace dialogue box, be sure to check "Search using regular expressions" and "match case". Leave the Replace field blank.
The result will be this text only: What is your name?
I am working on Google spreadsheet. I am trying to make a validation rule on the text length.
For example the text length must be equal to 12 characters which includes number, on dash and one capital character.
Example:
123-56C89112
I tried to search in google groups but no result! can you help in this please
You can use Data > Validation > Custom Formula is
=REGEXMATCH(B3, "^(?=.{12}$)(?=(^[^A-Z]*[A-Z]{1}[^A-Z]*$))(?=(^[^-]*[-]{1}[^-]*$)).*")
I'm not an expert on Regex so this may be a bit over the top, but it appears to work:
^(?=.{12}$)(?=(^[^A-Z]*[A-Z]{1}[^A-Z]*$))(?=(^[^-]*[-]{1}[^-]*$)).*
Debuggex Demo
This allows any string with exactly 12 characters, 1 upper case letter and 1 dash.
EDIT: The (Lookahead) Regex doesn't seem to work in Spreadsheets (see comment)
EDIT2: Using a custom function like the following seems to work, but only if you use warnings (instead of rejections) for some reason (bug?)
function test(myString) {
return myString.match("^(?=.{12}$)(?=(^[^A-Z]*[A-Z]{1}[^A-Z]*$))(?=(^[^-]*[-]{1}[^-]*$)).*")!=null;
}