Can custom formula based conditional formatting use NamedRanges ?
I'm experiencing that when named range is used, I cannot save the conditional formatting because formula is invalid, but when the NamedRange is replaced by a string it works. The docs do not allude to details, AFAIK.
ISNUMBER(INDIRECT("ArrivalTimes!$A$4:$S$653")) // OK
ISNUMBER(INDIRECT(RNG_ArrTimes)) // now allowed to save
Is this expected behaviour? Any docs available on this?
EDIT; based on answer for reader convenience.
AS suggested by #pnuts, it works when the range name is within double quotation marks.
However, while INDIRECT expects a string, in Sheets INDIRECT accepts NamedRanges as is without quotation marks. But, for conditional formatting, the named range must be within quotation marks. I have not found any docs that document or explain this behavior.
Can custom formula based conditional formatting use NamedRanges ?
Indeed they can.
The rest of your Q is unclear to me but perhaps it is just that you are missing double quotes around the Name of your range (and = at the beginning?).
Related
I've found there are 2 regex languages in Google Sheets.
First is used in formulas:
REGEXEXTRACT
REGEXREPLACE
REGEXMATCH
Second is used in QUERY
=QUERY({A4:C};"where Col1 matches 'West|East'")
The syntax for regular REGEX-like formulas is described here:
https://github.com/google/re2/blob/main/doc/syntax.txt
I've done quick research for QUERY regex and made this table:
You may see I've found some interesting differences about QUERY regex:
always matches the whole string, and you need to add .* if needed.
surprisingly supports "Lookahead" (?=group)
cannot use flags (?i), (?m)
by default fetches single lines of text only, but supports newline \n
Do you have your own research, or found some official docs?
Sheets specific functions
As you stated, there are three different Sheets functions that make use of this "matching" functionality: REGEXEXTRACT, REGEXREPLACE and REGEXMATCH. They accomplish different goals yet their syntactical implementation is pretty similar. You can find their documentation here:
REGEXEXTRACT. Documentation.
REGEXREPLACE. Documentation.
REGEXMATCH. Documentation.
And, as you stated, the full documentation on the syntax they use can be found here: https://github.com/google/re2/blob/main/doc/syntax.txt
Query function
The QUERY function (you can read its documentation here) uses the well-known SQL syntax, (notwithstanding the few exceptions listed in the documentation where they differ). In the official documentation there is a summary about basic SQL syntax (here), but of course for more detail you would need to go to the SQL documentation.
I thought this would've been one of the simplest ways to use conditional formatting, but apparently not.
To simplify I have two cells, B5, which derives it's value of 858 from a formula; and D2 which derives it's value of 712 from another sheet (which pulls the data from an API).
I've added conditional formatting to B5, that says "When the value of B5 is greater than the value of D2, format the cell background to green."
Or at least that's what I thought the conditional formatting rule said...
Here is a SS of the formatting rule: https://i.imgur.com/NCpl4o6.png https://i.imgur.com/sJc5Fli.png
I've found several sources online stating to use a custom formula '=B5>D2', but this does not work either. https://i.imgur.com/hBvQ7cm.png
Does anyone understand why this isn't working? and what the formatting rule I've written is actually saying?
Edit:
In case it's of any use the explicit value of B5 is '=C2*0.6'; and the explicit value of D2 is '=JSON!B2'.
If the solution involves manipulating the '*0.6' from B5, that value changes over the range I eventually want to apply the conditional formatting to.
With CF rules, everything but "Custom formula" requires literals. That is why your formulas don't work (i.e., formulas aren't literal values).
When using custom formulas, they are relative to the key cell. In your case, that is B5. So I would expect your custom formula =B5>D2 to work.
Unless...
... your D2 value is coming in formatted as a string. In that case, try the following custom CF formula:
=B5>D2*1
The addition of *1 should be enough to convert a string to a value within the formula.
I am converting a Google Sheets file into a CSV format.
Some cells have an image inserted into them via =IMAGE("https://placekitten.com/200/300")
I need to be able to extract in plain text https://placekitten.com/200/300
Is this possible? I've tried SUBSTITUTE but of course that doesn't work.
Thanks to whoever can solve this!
try:
=REGEXEXTRACT(FORMULATEXT(A2); """(.*)""")
I thought that explaining #player0’s answer would be nice, especially for future people.
His answer can be split in 2 parts:
Using FORMULATEXT to get the formula
Using a regular expression to extract the URL from it
The first part is FORMULATEXT. It is pretty self explanatory: it takes a cell and returns the formula as string.
The second part is using a regular expression (see wikipedia article and documentation on the exact syntax used by Google) to extract the URL. In this case #player0 relies on the fact that the URL is the only quoted text of that formula. So using the regex "(.+)" will match the quoted part inside the quotes of the formula, and thus only the URL. When using literal strings in a formula, you need to surround them with quotes (eg hello as "hello"). Double quotes need to be doubled (eg aaa"aaa is written as "aaa""aaa"). So "(.+)" becomes """(.+)""".
References
FORMULATEXT (Docs Editors Help)
REGEXEXTRACT (Docs Editors Help)
Regular expression (Wikipedia)
RE2 syntax (Google’s RE2 repository on GitHub)
I'm reading currency values from a website and I'd like to do some calculations with these numbers. They come in this format:
$7,821.24
Here's an example file:
https://docs.google.com/spreadsheets/d/1vHEH_m16KXcDh7hY_BVG9lur1huFjWOnx5bWtgrdGdA/edit?usp=sharing
Now for some reason neither VALUE() and TO_PURE_NUMBER work for me (Can't parse to numberic value, telling me it's a text value).
My guess is that the comma and the $-sign confuse the formula, is there anything I can do to format this correctly? The dollar sign always appears in the values but the comma only appears separating thousands of values.
I just started using Sheets for this so I absolutely have no clue. Would really appreciate if someone could help me out.
Thanks for your time!
Issue:
It's a locale problem. The value coming from IMPORTXML is formatted as in United States locale, so your spreadsheet (which uses a different format) cannot convert it.
Solution #1. Changing locale:
If the spreadsheet locale is changed to United States or others with the same format (via selecting File > Spreadsheet settings and setting the mentioned locale), the retrieved value will be a number, and you can work with it without using any other formula.
Solution #2. Formula:
If changing the locale is not an option, one possible way to convert the value to a valid number in your locale is the following formula:
=SUBSTITUTE(SUBSTITUTE(RIGHT(A2;LEN(A2)-1);",";"");".";",")
Changing locale didn't work in my case. But I was able to split the number which google sheet isn't detecting as a real number. So split it with "," and "." and any currency sign you may have, and then combine individual values for desired output
Is there a way to take a text in a cell that says 5*5 and to parse to make the result 25... using QUERY function or any of the other built-in functions...?
it would be like this:
=QUERY(SPLIT(B19, "*"), "select Col1*Col2 label Col1*Col2''")
No. But if you have all such Mathematical expressions in a defined range(say,A5:A7), then you can use Find and Replace
FIND:
^
REPLACE:
=
Range:
Sheet1!A5:A7
Checkmark "Search using regular expressions". Click Replace all. Otherwise you'll need scripts.
IF you are just looking to parse simple mathematical expressions (+,-,x,/), then it can be done, but not in a single formula.
First, you can split the text based on your math operator, which will provide the numbers. Then you can use regexextract to output the math operator, then use a nested if to perform the needed math operation on the numbers, based upon that operator. You can hide the intermediate columns to put the answer next to the original.
Note that if you need to do more complex operations or operations on more than two numbers, this will not work.