TEXT() equivalent for strings in Google Sheets? - google-sheets

In Google Sheets, TEXT() can format numbers but I cannot find one for strings.
For example,
TEXT(012345678,"00-000-0000")
formats the number into
01-234-5678
I want to do a similar thing but with strings, like:
AABCDEEEF to AA-BCD-EEEF
I guess using several functions can yield the same result but I want to know if there is a simple method, like TEXT().

I believe your goal as follows.
You want to convert AABCDEEEF to AA-BCD-EEEF.
How about this sample formula?
Sample formula:
=ARRAYFORMULA(REGEXREPLACE(A1:A5,"(.{2})(.{3})(.{4})","$1-$2-$3"))
In this case, I used REGEXREPLACE.
When you want to use only one cell, please use REGEXREPLACE(A1,"(.{2})(.{3})(.{4})","$1-$2-$3")
Result:
Reference:
REGEXREPLACE

Related

Google Sheets, how can I remove or strip specified strings

I'm using Google Sheets and trying to figure out a formula that strips or removes specific strings. So a cell might have:
[url=https:website1]https:website1[/url] [url=https:website2]https:website2[/url]
and I want to convert it to
https:website1 https:website1
Each cell in the column will have different "websites" but the formatting will be similar. Any help is appreciated.
I've tried REGEXEXTRACT and SUBSTITUTE functions but can't seem to figure it out.
can you try:
=BYROW(A2:A,LAMBDA(ax,IF(ax="",,TEXTJOIN(CHAR(10),1,INDEX(REGEXEXTRACT(SPLIT(ax,"[url=",0,0),"[^\]]*"))))))

Sumifs with or conditional in Google Sheets

I have a database and I need to create a sumifs expression in Google sheets with the following rules: I have a range of cells and this would be a filter for what the sumifs must sum (similar to an OR). I think the image will explain a little bit better what my expected result is:
I have been trying with a lot of examples but none of them have given me the right result.
You can filter the values and then sum up:
First one would be: =SUM(FILTER($B$1:$B$6;$A$1:$A$6=$F$4:$F$6))
Second one: =SUM(FILTER($B$1:$B$6;$A$1:$A$6=$I$4:$I$5))
You can see an example I uploaded to GDrive

ARRAYFORMULA && Extract Num From String

Trying to use an arrayformula on google sheets to auto-populate a column which will extract the number from a string. I've found / made multiple methods of extracting the number from the string, but I can't seem to get it to work in an arrayformula.
This formula works perfectly to extract the text, but because it's creating an array it's not working within the array formula.
TEXTJOIN("",TRUE,IFERROR((MID(H13,ROW(INDIRECT("1:"&LEN(H13))),1)*1),""))
This below just won't work. I've tried multiple methods, but can't get it working. Clearly I'm making a circular reference, but I can't see to solve it.
=ARRAYFORMULA(IF(ROW(C12:C)=12, "Num", IF(ISBLANK(C12:C), "", TEXTJOIN("",TRUE,IFERROR((MID(H13:H,ROW(INDIRECT("1:"&LEN(H13:H))),1)*1),"")))))
Included is an example worksheet, with a column with expected output.
Thanks for your time! :)
Example Worksheet
What you could try, as I demonstrated in M13 on your sheet, is to use REGEXREPLACE() to remove anything from your data that is not a digit through "\D":
=INDEX(IF(H13:H="","",REGEXREPLACE(TEXT(H13:H,"#"),"\D","")))

How can I use nested formulas in the ARRAYFORMULA function in Google Sheets?

I need Google Sheets to compute sums for each row using the arrayformula() function.
I know I can manualy enter somthing like;
=ARRAYFORMULA(A:A + B:B + C:C)
but I need the use of the functions to do it.
I've tried many things including;
=ARRAYFORMULA(sum(A:A,C:C))
Here is a sample file that I could use help with.
This formula works in cell G3 of your test sheet:
=ArrayFormula(mmult(ARRAYFORMULA(IF(ISBLANK(A3:C),0,A3:C)),sign(transpose(column(A3:C)))))
I've used a custom format to hide the zero values on the empty rows as well
Formulas
Addition (SUM)
QUERY function
=QUERY(A3:C20,"Select A+B+C Label A+B+C ''")
Concatenation
& operator
=ArrayFormula(J3:J20&K3:K20&L3:L20)
CONCAT function
=ArrayFormula(CONCAT(CONCAT(J3:J20,K3:K20),L3:L20))
Explanation
Besides ARRAYFORMULA, Google Sheets has QUERY, FILTER, ARRAY_CONSTRAIN, among other functions that could help you to handle array operations. Take a look to Function List to have the complete list. Also could be very helpful that you to take a look to Using arrays in Google Sheets.

What's the right tool for this job?

Is it possible to nest simple programs within a Google Sheets, similar to how you would with Visual Basic for Applications in Excel? Or alternatively a simple = syntax using regex, if there is a way to do that in Google Sheets?
I want to take a list of multiple names (name1, name2, name3) in a single cell from across multiple identical sheets and transpose them to another sheet within the same spreadsheet, check for duplicates and ignore capitals, etc. Is there a way to do this?
You are asking for an easy answer to a composite problem. To solve this, I would split the job into separate chunks:
Split the input cell content into
different cells. As it is unclear
how this format is, I cannot advice
on any specific method. Check out
ImportRange function or similar.
Transpose them. use =TRANSPOSE(area)
Remova duplicates, use =UNIQUE(area)
Check the Google Spreadsheet function list for details.
Nest them: =UNIQUE(TRANSPOSE(A1:C15)).
LOWER cannot be used in this nest as it works with only text input, not array input. Although you can use it for the first input cell.

Resources