I am trying to count the number of cells that contain the symbol "?" in a specific range.
But the formula =COUNTIF(C3:C60; "?") seems to interpret the char as 'any string with one char'.
I tried with "\?", "'?" and "'?'".
I tried this solution too : =SUM(IF(A2:A10="?"; 1; 0))
Is there an other solution to escape the char and just take it as it is ?
The wildcard escape character for COUNTIF as per the function help page is a tilde:
=COUNTIF(C3:C60;"~?")
try regex it:
=SUMPRODUCT(REGEXMATCH(C3:C60; "\?"))
Related
I'm trying to do a conditional formatting that matches on the double quote character followed by a zero. i.e.
"0 / 10" : this should match as true
"10 / 10": this should match as false
This regex is incorrect, as it matches on both:
=REGEXMATCH(B:B;"0 /")
I expect to be able to use the formula standard of escaping the " with an extra quote. It accepts this formula syntactically, but does not match:
=REGEXMATCH(B:B;"""0 /")
I tried matching with punctuation characters, no match:
=REGEXMATCH(B:B;"[[:punct:]]0 /")
I can use [digit[ to match the 10/10 case, but ~digit doesn't match the zero with a quote in front of it:
=REGEXMATCH(B:B;"[^[:digit:]]0 /")
I even tried concatenating the specific character, no match:
=REGEXMATCH(B:B;CONCATENATE(CHAR(34), "0 /"))
I'm very confused at this point. If I insert any other special character before the zero, I have no trouble matching it. But it seems like double-quote just isn't treated like a regular character somehow. Does anyone know what I'm doing wrong?
Try
=REGEXMATCH(B2;char(34)&"0 /")
Thanks to Tim for giving me a hint that lead to a solution. My problem was that the text in a cell was part of a formula. So I needed to extract the formula as text (FORMULATEXT) and then it works:
=REGEXMATCH(FORMULATEXT($B1);"""0 /")
Try this in row 1 of a different column:
=arrayformula(if(B:B<>"",iferror(regexmatch(B:B,"""0"),),))
if(B:B<>"" will only process the formula provided Col B has values.
iferror( will ignore numbers in Col B that produce #VALUE!.
"""0" is the regex. The double quote to the left of 0 is doubled up (or char(34)&"0" as per #Mike Steelson).
I am trying to build a URL in a cell (google sheets) which will get some of its values from different cells. I have tried using all different ways I can think of like concatenate, Join, & etc but the problem is that the URL has some curly brackets and " as a requirement and that breaks the formula:
URL Example
https://katang.io/?t_pid=1&t_extra={"Source":"stackoverflow","Type":"email","Stategy":"banner"}
So I need "Source":"stackoverflow" to be dynamic
so for example "Source":"Get Value from Cell A1"
Any Help or guidance will be much appreciated
Things to note:
"" makes a literal " character in a string, so you'll have to double up every one.
The & is the concatenation operator in a formula, so you can use that to get values outside of your string.
Therefore, this formula should work:
="https://katang.io/?t_pid=1&t_extra={""Source"":"""&A1&""",""Type"":""email"",""Stategy"":""banner""}"
I am trying to perform a text replacement over multiple cells. I'm sure I can do this using ARRAYFORMULA, but I'm not sure how to feed SUBSTITUTE with an array rather than a single value.
I have tried using =ARRAYFORMULA(SUBSTITUTE(A1:A, '&', '&')) but this gives a formula parse error.
What is the correct formula to use?
You need to use the double quotation marks " instead of the single quotation marks '
=ARRAYFORMULA(SUBSTITUTE(A1:A, "&", "&"))
Sample
Code:
=ArrayFormula((VLOOKUP(QUERY(UNIQUE(RANDBETWEEN(ROW(INDIRECT("A1:A"&COUNTA(A:A)*10))^0;COUNTA(A:A)));"limit 4");{ROW(INDIRECT("A1:A"&COUNTA(A:A)));FILTER(A:A;A:A<>"")};2;0)))
I'm trying but got this error,
test 1
Can anyone tell what's wrong? To make my code
to work as in the first picture
error in #REF!
VLOOKUP evaluates outside the range bounds.
im try change code
=ArrayFormula((VLOOKUP(QUERY(UNIQUE(RANDBETWEEN(ROW(INDIRECT("A1:A"&COUNTA(A:A)*10))^0,COUNTA(A:A))),"limit 4"),{ROW(INDIRECT("A1:A"&COUNTA(A:A)));FILTER(A:A,A:A<>"")},1,0)))
but number
solution for that?
=ARRAYFORMULA(VLOOKUP(FLOOR(RANDARRAY(5)*COUNTA(A2:A)),{SEQUENCE(COUNTA(A2:A),1,0),A2:INDEX(A2:A,COUNTA(A2:A))},2))
Create 5 random integers using RANDARRAY between 0(inclusive) and number of entries in A2:A(i.e., COUNTA)(exclusive).
Create a artificial side by side array({arr1,arr2}) of SEQUENCE of numbers (from 0) and actual values in A2:A
VLOOKUP the random integers in the created artificial array to give random values in A:A
If you're in locales that use comma as decimal separators, The artificial array should be created using \ instead of ,({arr1\arr2}).
=ARRAYFORMULA(VLOOKUP(FLOOR(RANDARRAY(5)*COUNTA(A2:A));{SEQUENCE(COUNTA(A2:A);1;0)\A2:INDEX(A2:A;COUNTA(A2:A))};2))
On the first formula
{ROW(INDIRECT("A1:A"&COUNTA(A:A)));FILTER(A:A;A:A<>"")}
replace the semicolon ; between INDIRECT() and FILTER() by a backslash \ as using a semicolon appends the results of FILTER to the results of INDIRECT but you are looking to put the results of each function on their own column. Please note that this formula is using semicolons as argument separator.
On the second formula replace the semicolon ; between INDIRECT() and FILTER() by a comma , (and replace the third argument of VLOOKUP, 1, by 2. Please note that this formula is using commas as argument separators.
Explanation
Commas are used as argument separator on spreadsheets that use dot as decimal separator (=SUM(1,2,3)) but also use commas as columns separator on arrays ({"a","b"})
Semicolons are used as argument separator on spreadsheets that use comma as decimal separator (=SUM(1;2;3)). On these spreadsheets, backslashes are used as columns separator on arrays ({"a"\"b"});
References
Using arrays in Google Sheets
Looking to take a string along the lines of:
"text": "fkjhsabhfkjhs7g8ydfgd.",
"e": 1541699908958,
"test": true
and only extract the characters between the text field...so end up with only fkjhsabhfkjhs7g8ydfgd.
The length of the text field can vary
Tried this: =REGEXEXTRACT(C2,"""(.*?)""") with no luck
I found that if you escape the double double quotes, that it works. The other examples don't appear to work in Google Sheets regexextract function
=REGEXEXTRACT(C2,"\""(.*?)\""")
An alternative solution could be
=regexextract(C2, "\:\s""(.+?)""")
I'm not sure if Excel does capture groups properly, but if your input has no double quotes inside, you could try:
=REGEXEXTRACT(C2, "[^""]+")
which matches up to the second double quote (eg. matches abc in "abc"d").
Change A1 with your designated cell number and it should work
=REGEXEXTRACT(A1,"""(.*?)""")