I have some strings inside Google Sheets, containing simple arithmetic expressions:
Is there a way to evaluate these expressions without the need for writing a script? (i.e. formula only)
try:
=INDEX(QUERY(; "select "&A6); 2)
Related
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)
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.
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?).
How can I use mkAnd to join three terms. For example, I have a1=1,a2=3,a3=10. Now I want to use produce formula: (and (and a1=1 a2=3) a3=10). I use mkAnd(a1,a2,a3), it only gives me the wrong formula (and a1=1 a2=3 a3=10).