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.
Related
I have one column with comma separeted strings and a several with words that can be in these strings. I have to find if a a word from a column name is in a string. I used a regexmatch formula, but it doesn't distinguisch TV from TV remote. How can I fix this?
Mu formula:
arrayformula(if(L1<>"";if(REGEXMATCH($K$2:$K;L$1)=TRUE;"Wybrano";"");""))
My data
Or if it will be simplier I have to count how many times the certain word occured in the column with strings.
Can you try:
=MAKEARRAY(ROWS(K2:INDEX(K2:K;ROW(LOOKUP("ZZZ";K:K))));COUNTA(L1:1);LAMBDA(r;c;IF(LEN(INDEX(K2:K;r));IF(REGEXMATCH(INDEX(K2:K;r);INDEX(L1:1;;c)&"(?:,|$)");"Wybrano";);)))
Adjust the column range here COUNTA(L1:1) to something like COUNTA(L1:P1) or so depending on your dataset.
try:
=IFNA(BYCOL(L1:P1, LAMBDA(y, BYROW(K2:K, LAMBDA(x,
IF(MATCH("*"&y&"*", x, ), "Wybrano"))))))
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]", ))
How do I go about using REGEXREPLACE to insert commas into values in Google Sheets? Example:
cell A1 = 1234567890
expected output in B1 = 1,234,567,890
edit:
The intention would be so that the user would not need to format anything themselves. This issue is from a template I'm doing up, sample sheet here - https://docs.google.com/spreadsheets/d/1n-KXqcSpx_DpvrOv9A4UsKn1amGGEUCpyzWWDphWdJY/edit?usp=sharing
try:
=TEXT(A1; "#,###,###,##0")
Try
=A1
and change the format to
#,##0
To insert commas into values in Google Sheets, I recommend:
Select the range of cells you'd like to format or modify.
Click Format and then Number.
Select the format to apply to the range of cells.
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))
I am trying to use substitute function inside a query function but not able to find the correct syntax to do that. My use case is as follows.
I have two columns Name and Salary. Values in these columns have comas ',' in them. I want to import these two columns to a new spreadsheet but replace comas in "Salary" column with empty string and retain comas in "Name" column. I also want to apply value function to "Salary" column after removing comas to do number formatting.
I tried with the following code but it is replacing comas in both the columns. I want a code which can apply the substitute function only to a subset of columns.
Code:
=arrayformula(SUBSTITUTE(QUERY(IMPORTRANGE(Address,"Sheet1!A2:B5"),"Select *"),",",""))
Result:
Converted v/s Expected Result
Note :
I have almost 10 columns to import and comas should be removed from 3 of them.
Based on your suggestions, I was able to achieve the objective by treating columns separately. Below is the code.
=QUERY({IMPORTRANGE(Address,"Sheet1!A3:A5"),arrayformula(VALUE(SUBSTITUTE(IMPORTRANGE(Address,"Sheet1!B3:B5"),",","")))},"Select * where Col2 is not null")
Basically, two IMPORTRANGE functions side by side for each column.
The same query on the actual data with 10 columns will look like this.
=QUERY({IMPORTRANGE(Address,"Sheet1!A3:C"),arrayformula(VALUE(SUBSTITUTE(IMPORTRANGE(Address,"Sheet1!D3:H"),",",""))),IMPORTRANGE(Address,"Sheet1!I3:J")},"Select * where Col2 is not null")
I used 3 IMPORTRANGE functions so that I can format the columns D to H by removing comas and changing them to number.
My suggestion is to use 2 formulas and more space in your sheets.
Formula #1: get the data and replace commas:
=arrayformula(SUBSTITUTE(IMPORTRANGE(Address,"Sheet1!A2:B5"),",",""))
Formula #2: to convert text into numbers:
=arrayformula (range_of_text_to_convert * 1)
Notes:
using 2 formulas will need extra space, but will speed up formulas (importrange is slow)
the second formula uses math operation (*1) which is the same as value formula.
Try this. I treats the columns separately.
=arrayformula(QUERY({Sheet1!A2:A5,SUBSTITUTE(Sheet1!B2:B5,",","")},"Select *"))
Thanks to Ed Nelson, I was able to figure out this:
=arrayformula(QUERY({'Accepted Connections'!A:R,SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE('Accepted Connections'!A:R,"AIF®",""),"APA",""),"APMA®",""),"ASA",""),"C(k)P®",""),"C(k)PS",""),"CAIA",""),"CBA",""),"CBI",""),"CCIM",""),"","")},"Select *"))
That removed all the text I didn't need in specific columns.