Extract dollar amount in sheets text cell - google-sheets

Ideally what I'm looking for is to get the dollar amount extracted no matter the format.
Sheet link:
https://docs.google.com/spreadsheets/d/1drTPlnQmVTsbUXwJDfQr7DnHjSbnGx-fLthad6KxfM8/edit?usp=sharing

Delete everything from Column B, including the header. Then place the following formula in cell B1:
=ArrayFormula({"Header"; IF(A2:A="",,VALUE(IFERROR(REGEXEXTRACT(A2:A,"\$(\d+\.?\d*)"))))})
You may change the header text within the formula as you like.
If a cell in A2:A is blank, the corresponding cell in B2:B will be left blank as well.
Otherwise REGEXEXTRACT will look for a pattern that begins with a literal dollar sign. The parenthesis within the quotes denote the beginning and end of a capture group (i.e., what will be returned if found) following that literal dollar sign. The pattern \d+\.?\d* means "a group of one or more digits, followed by zero or one literal period symbols, followed by zero or more digits."
IFERROR will cause null to be rendered instead of an error if such a pattern is not able to be extracted.
VALUE will convert the extracted string (or null) to a real number.
If you would prefer that null be returned instead of 0 where no pattern match is found, you can use the following variation of the formula instead:
=ArrayFormula({"Header"; IFERROR(VALUE(IFERROR(REGEXEXTRACT(A2:A,"\$(\d+\.?\d*)"),"x")))})
If your strings may include numbers with comma separators, use the following versions of the above two formulas, respectively:
=ArrayFormula({"Header V1"; IF(A2:A="",,VALUE(IFERROR(REGEXEXTRACT(SUBSTITUTE(A2:A,",",""),"\$(\d+\.?\d*)"))))})
=ArrayFormula({"Header V2"; IFERROR(VALUE(IFERROR(REGEXEXTRACT(SUBSTITUTE(A2:A,",",""),"\$(\d+\.?\d*)"),"x")))})

try:
=INDEX(IFNA(REGEXEXTRACT(A2:A, "\$(\d+.\d+|\d+)")*1))

Related

How to change to a specific domain on each cell in Sheets

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."

Google Sheets Extract Text between two characters

I have a field where I need to extract the text between two characters.
I've found regexextract and I got it to work when there is one character but I can't for the life get it to work with multiple characters.
2020-02: Test Course (QAS)
I need to extract text after : and before (
So it would just return "Test Course"
TYIA
If it's for just one cell (say A2):
=IFERROR(TRIM(REGEXEXTRACT(A2,":([^\(]+)")))
This will return what you want regardless of spaces after the colon or before the opening parenthesis. If no match is found, null will be returned.
If it's to process an entire range (say, A2:A), place the following in, say, B2 of an otherwise empty Col B:
=ArrayFormula(IF(A2:A="",,IFERROR(TRIM(REGEXEXTRACT(A2:A,":([^\(]+)")),A2:A)))
This will return what you want regardless of spaces after the colon or before the opening parenthesis. If no match is found, the original string will be returned.
In both cases, the REGEX string...
:([^\(]+)
... means "a grouping of any number of characters that aren't an opening parenthesis and which follows a colon."
One way to do that would be with the INDEX() and SPLIT() functions like this:
=TRIM(INDEX(SPLIT(A2,":("),2)
Split splits the text into 3 parts using the : and (, then INDEX chooses the second part.
The TRIM() just gets rid of the spaces.

Random Cells From A List In Google Sheets

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

Combine Data From Separate Columns with a Delimiter with Arrayformula

This is the example sheet.
Alright, in cell V1!A1 is the formula ={"Languages";ARRAYFORMULA(TRANSPOSE(QUERY(TRANSPOSE(B2:F&","),,COLUMNS(B2:F))))}. I need to combine data from B2:F with the delimiter ,. But now I need to delete the unnecessary delimiters.
In sheet V2, I tried ={"Languages";ARRAYFORMULA(REGEXREPLACE(REGEXREPLACE(TRANSPOSE(QUERY(TRANSPOSE(B2:F&","),,COLUMNS(B2:F))),"(^(,(\s,){4})$)|(^(,\s)+)|(,(\s,)?\s?$)",""),"(,\s,)+\s?",", "))} but it's not consistant and still leaves delimiters in the output.
Is there a better way to do this?
I added a sheet called "Erik Help" which replaces your formula with the following:
=ARRAYFORMULA({"Languages";SUBSTITUTE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(B2:F&" "),,COLUMNS(B2:F))))," ",", ")})
Essentially, instead of appending a comma to elements of the range B2:F, I appended a space. Then I applied TRIM to the results, which will leave no spaces before or after each concatenation and only one between each element. To that, I applied a SUBSTITUTE of the single spaces with a comma-space.

Is it possible to assign conditional formatting to a named range in Google Sheets?

I'd like to apply a conditional formatting rule to a named range. Is that even possible? How do I do that? When trying to enter the Name of the Range to the Field where you set up the range the rule applies to it won't accept my input.
Also with INDIRECT it does not work:
this is not possible in Google Sheets
for the custom formula you need to wrap it into INDIRECT formula like:
I think it is not possible, it is not documented in official docs.
Range names:
Can contain only letters, numbers, and underscores.
Can't start with a number, or the words "true" or "false."
Can't contain any spaces or punctuation.
Must be 1–250 characters.
Can't be in either A1 or R1C1 syntax. For example, you might get an error if you give your range a name like "A1:B2" or "R1C1:R2C2."
The following works for my specific use case, where the named range is an "unknown" number of rows.
In this case, A1 is a column heading, and is not part of the named range.
A2:A5 is currently assigned to the named range, CitationType.
Conditional formatting is applied to A1:A based on the formula:
=and(row(A1)>1,row(A1)<=1+rows(indirect("CitationType")))
I did not find an easy way (without scripting) to get the address details of a named range, allowing for "arbitrary" usage in conditional formatting.
For custom formulas in Sheets conditional formatting, the formula usually accesses a column value in the first row of the format range. Named range values can be used in custom formulas using INDIRECT function.
example from my case ... a list of "brackets" in a tournament. Bracket rows are coloured depending on what bracket the row is for (e.g. brackets 1-10), that value is in the E column.
The formula specifies the appropriate column in the first row of the range (row is relative as conditional formatting iterates over the range). Since my range is B2:G1005, the formula references cell $E2 (the bracket ID) and compares it to the bracket id stored in a named-range location (BID_1), so custom formula is:
=$E2=INDIRECT("BID_1")
(if bracket matches the ID assigned to bracket 1 -- colour the cells grey with bolded black text).
Screenshot of conditional formatting using a named range

Resources