I'm trying to use regex to remove numbers from Column C using the formula below. it works for one cell but not for multiple. I want to apply the formula to the whole c column starting from C7
=REGEXREPLACE(C7:C, "[0-9]*\.[0-9]|[0-9]","")
Any advice?
use:
=INDEX(REGEXREPLACE(C7:C, "[0-9]*\.[0-9]|[0-9]", ))
Related
Here is a screenshot of and a link to my test spreadsheet. It makes the requirements very clear:
https://docs.google.com/spreadsheets/d/1rZr2zHaSkff9SFpwpx83_4TawruotA1jhOKqW6uYDz0/edit?usp=sharing
The formula I have come up with is very close to what I need, but "linkText" is a placeholder for the value of the array item. Here is my formula:
=if(A2="","","<a href='https://samplewebsite.com/search?q=" & trim(lower(substitute(A2,",","'>linkText</a>, <a href='https://samplewebsite.com/search?q="))) & "'>linkText</a>")
try:
=index(join(","&char(10), SUBSTITUTE($B$1, "linkText", split(A3, ","))))
Drag down to column.
Result:
First using SPLIT to split the strings between comma from the column A. Then using SUBSTITUTE to find the string "linkText" from the text in B1 and replace it with the strings from the returned strings from the split function. Then joining them all together.
NOTE: Just keep the reference string in a fixed cell in your sheet. <a href='https://samplewebsite.com/search?q=linkText'>linkText</a> to be used in the formula. As seen in above screenshot it is fixed in cell B1.
Alternate Solution using ArrayFormula:
You can also use it with arrayformula so you only have to put it in the first row and no need to drag down the formula to the column, it will automatically be expanded down just make sure to clear the cells below or it will throw an error.
=arrayformula(regexreplace(substitute(transpose(query(transpose(IF(IFERROR(SPLIT(A2:A, ","))<>"", "♦<a href='https://samplewebsite.com/search?q="&SPLIT(A2:A, ",")&"'>"&SPLIT(A2:A, ",")&"</a>", )),,9^9)), "♦", char(10)), "^\s", ""))
Result:
You may also have a look in below references for more information.
References:
SUBSTITUTE
SPLIT
JOIN
Comma separated list into matched columns pairings
I'm trying to count instances of letters (like letters C through Z, excluding RR) within the same column if they are listed next to a name. Here's my sample Google Sheet that you can edit.
I'm trying to insert the formula in cell F3 that is highlighted yellow. So far I have...
=arrayformula(SUM(COUNTIFS(A2:A,{"C","D","E","F","G"},C2:C,E3:E)))
It seems like what I have should work, but it's giving me a #VALUE error, saying, "ARRAY arguments to COUNTIFS are of different size".
It seems like REGEXMATCH could be used inside the COUNTIF formula to make it easier to restrict the search to the range of letters I need, but not sure how to construct the formula.
Thanks for your help!
UPDATE
This formula below works but only for column A. I actually need to specify a different range of letters to be counted in column B and totaled in column K.
=QUERY(A2:C,"select C,count(A) where A matches 'C|D|E|F|G|H|I|J|K' group by C label count(A)''", 0)
Seems like this post almost answers it.
Current progress:
={QUERY(A2:C,"select C,count(A) where A matches 'C|D|E|F|G|H|I|J|K' and A is not null group by C label count(A)''", 0),QUERY(A2:C,"select count(B) where B matches 'F|G|H|I|J|K' and B is not null group by C label count(B)''", 0)}
As we have discussed / tested on your sample sheet. This should work as close as possible to the data that you would want to filter/display.
A 2-formula solution was found to work as well. Answer is in the same spreadsheet linked above in Sheet2. It should prevent the first formula from not working should someone need a different one.
J2 - =QUERY(A2:C,"select C,count(A) where A matches 'C|D|E|F|G|H|I|J|K' group by C label count(A)''", 0)
L2 - =ArrayFormula(IFNA(vlookup(J2:J,QUERY(A2:C,"select C,count(B) where B matches 'F|G|H|I|J|K' group by C label count(B)''", 0),2,0)))
This formula should work for you if you paste it in cells F3 to F7.
I currently have cells P1 to P26 (you'd probably want to hide this column) occupied with the letters of the alphabet in order, making it so that you can select P3:P26 (C-Z) to put into your first condition for your COUNTIFS.
=arrayformula(SUM(COUNTIFS(A2:A, $P$3:$P$26,C2:C,E3)))
You'll have to implement these formulas in the other places that you want them too, but it shouldn't be hard to change this formula to work in the other places as well.
I need to format the numbers in a column like this:
08146.000331/2021-32
But, when I use the following format
00000"."000000"/"0000"-"00
The result is
08146.000331/2021-30
What am I doing wrong?
There is a formula to achieve the aimed result?
This is the actual sheet: link
Some of the values in column C are numbers and some are text strings that look like numbers.
Click in column C and choose Insert > Column right to create a new column D. Then insert this formula in cell D4:
=arrayformula(
{
"Formatted SEI";
regexreplace(trim(C5:C); "^(\d{5})(\d{6})(\d{4})(\d{2})$"; "$1.$2/$3-$4")
}
)
The formula converts all values to text strings and inserts separators.
Try
000"."000"."000"-"00 ---> for CPF, and
00"."000"."000"/"0000"-"00 ---> for CNPJ.
For numbers with more then 14 digits, this type of formatting don't works due to numeric precision limit.
Um abraço.
I have a sample Spreadsheet such as
And I want to import data from this spreadsheet to another spreadsheet, but after comparing some data, such as
My noob formula for the selected cell name in the second image:
=Query(ImportRange("URL of first spreadsheet","sheet!B:D"),"Select Col2 where Col2=A.....(what to add here? this column 'A' is not working for comparing the names)
My Approach:
I will compare the values from the import range with the existing column i.e. previousSpreadsheet.name.A=thisSpreadsheet.this_name.A and compare every name and SELECT values accordingly for the next three columns (in yellow). I hope I'm clear.
What should I add here? Is my approach right? If not, What are the alternatives to achieve this?
Thanks.
EDIT
(following OP's request)
Also, can I compare two cols with one? such as where LOWER(Col2)='"&LOWER(A2)&"' or '"&F2&"' or Col2=A2 || F2 something like this? for comparing two cols with one?
If you start using more than one names as variables, you may want to consider using other alternatives for the where clause, like matches
=Query(ImportRange("URL of first spreadsheet","sheet!B:D"),
"Select Col2 where Lower(Col2) matches'"&LOWER({A2&"|"&F2})&"'")
Original answer
Please use
=Query(ImportRange("URL of first spreadsheet","sheet!B:D"),"Select Col2 where Col2='"&A2&"'")
(where A2 is the name you need)
Pay notice to the syntax referring the cell: single quotes ' double quotes" ampersand & cell A2 and again &"'.
No spaces in between
try:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A, IMPORTRANGE("ID", "sheet!B:D"), {1,2,3}, 0)))
I'm using the query function in google sheets... I want to select columns F to AB.
I need a cell that has the output F,G,H,I... ,AB so I can put it in the Select statement.
This formula should have 2 inputs, the starting letter (F in this case) and number of following columns (22 in this case)
No app script code please. I know someone can do it with just formulas in one cell.
I believe your goal as follows.
You want to create the value of F,G,H,I... ,AB by giving the start column letter of "F" and the number of columns of 22.
For example, when the start column letter of "F" and the number of columns of 22 are given, you want to retrieve the value of F,G,H,I... ,AB and you want to use this like =QUERY(A1:AB,"SELECT F,G,H,I... ,AB").
You want to achieve this using the built-in functions of Google Spreadsheet without the Google Apps Script.
For this, how about this answer?
Sample formula 1:
In this sample formula, in order to create the value of F,G,H,I... ,AB by giving the start column letter of "F" and the number of columns of 22, I would like to propose the following formula.
=TEXTJOIN(",",TRUE,ARRAYFORMULA(REGEXREPLACE(ADDRESS(1,COLUMN(INDIRECT(A1&"1:"&ADDRESS(1,B1+COLUMN(INDIRECT(A1&"1")),4))),4),"\d+","")))
When A1 and B1 have the values of F and 22, respectively, the flow of this formula is as follows.
Using COLUMN, retrieve the column numbers.
Using ADDRESS, retrieve the column letters from the column numbers. At that time, the row number os removed using REGEXREPLACE.
Above formulas are used with ARRAYFORMULA.
Using TEXTJOIN, join the column letters with ,.
Result:
Sample formula 2:
In this sample formula, =QUERY(A1:AB,"SELECT F,G,H,I... ,AB") is created using above sample formula 1.
=QUERY(A1:AB,"SELECT "&TEXTJOIN(",",TRUE,ARRAYFORMULA(REGEXREPLACE(ADDRESS(1, COLUMN(INDIRECT(A1&"1:"&ADDRESS(1, B1 + COLUMN(INDIRECT(A1&"1")), 4))), 4),"\d+",""))))
Result:
In this sample result, the range of A2:AB7 is used for QUERY. So please be careful this. When the cells "A1" and "B1" are changed, the result of this formula is also changed.
Note:
In this case, when the start column and the number of columns are more than the existing maximum columns, an error occurs, please be careful this.
References:
COLUMN
ADDRESS
REGEXREPLACE
ARRAYFORMULA
TEXTJOIN
Added:
When you want to create Col6, Col7, Col8 ... Col28 by giving the start column letter of "F" and the number of columns of 22, how about the following sample formula?
Sample formula:
="Col"&TEXTJOIN(",Col",TRUE,ARRAYFORMULA(COLUMN(INDIRECT(A1&"1:"&ADDRESS(1,B1+COLUMN(INDIRECT(A1&"1")),4)))))
In this case, please put F and 22 to the cells "A1" and "B1", respectively.
if your range is F:AB then you can skip select parameter or use:
=QUERY(F1:AB; "select *"; 0)
if the range is larger put the range in curly brackets and try:
=ARRAYFORMULA(QUERY({A1:AB}; "select "&TEXTJOIN(","; 1; "Col"&COLUMN(F:AB)); 0))