Combine 2 REGEXREPLACE Formulas Into One - google-sheets

In cell C5, I have a date with dashes ---> 01-31-2013
I just need to remove the dashes, extract only the first 4 digits in the date (in this case, 0131), and append 'Efisd' at the BEGINNING of the string.
So, the end result should look like this ---> Efisd0131
So far, I've been able to remove the dashes, and extract the first 4 digits of the date. But, I can't seem to put append 'Efisd' to the beginning and put it all together into one formula.
Does anyone know how to do this? Thanks for your help.
Here's the sample spreadsheet that you can edit

From just the input date you can get it done with this:
="Efisd"&left(substitute(B5,"-",""),4)
It substitutes the dashes for blanks, gets the left 4 characters, and ads Efisd to the front.

If anyone wants the arrayformula version of this, here it is below. Put formula in very top cell in column, edit the header in between quotes, and change cell values to fit your spreadsheet.
={"Your Header";arrayformula(iferror(if(len(M2:M),"Efisd"&left(substitute(M2:M,"-",""),4),""),))}

Related

How do I add a 0 in front of a string of numbers for all cells?

I need to add a 0 before all cells in the A column on Google Sheets. Is there a code or formatting function I can add in? I need them to look like A2. A3 is what I have right now. There are a total of 783 that were extracted like this and I don't wanna do this manually
I tried formatting a few ways but I'm still a beginner in Sheets & Excel
You can try with ARRAYFORMULA in another column:
=ARRAYFORMULA(0&A1:A)
=INDEX(0&A1:A)
(PS: you may change A1:A with A1:A783)
If you want to just change the values in that column, you may use FIND AND REPLACE --> (Edit -> Find and Replace), be sure you tick "Search using regular expressions". Put to find ^ and to replace 0
NOTE: thanks to #rockinfreakshow, prior this second option, first format to plain text:
And then do the replacement:
You can use this formula in the adjacent cell:
Then you apply it across all your rows.
Do not forget to copy and paste as values.

How can I get this formula to grab values between the commas?

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

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 add the content of a cell into a formula?

I've been trying to import some values from a JSON file but they keep adding things to the list and it's a big no-no for me (it has 2,000 rows of items already). I didn't see any information about this, and I don't understand the INDIRECT or ADDRESS functions.
Can anyone explain it a bit?
An example of what I'm doing.
I'm using Google Sheets not Excel and Sheets doesn't like unfinished formulae so when I try to concatenate the formula it adds the end brackets on mid formula!
You have to use a formula if you are attempting to concatenate strings in Excel.
What I do is put everything before the text to be inserted:
import("api.kitchen.utility/
into a cell, say E1, then the following text in E2:
"; "noheader,notruncate")
Assuming the text you want to include is in A1 - A??.
In B1 put the following formula:
=$CONCAT($E$1, $A1, $E$2)
Copy B1 and paste down to rest of range.
$E$1 means the pointer will always point to Cell E1 no matter what. The $A1 means the column will always will be 'A' but the row will increment when it is increased due to copy or fill.
A bare reference G10 (in H10) when pasted or filled always refers the the cell to the immediate right.
In other words add a $ to a row, column, or both to always point to the same row, column or cell.

Google new spreadsheet Split() function bug?

try this.
in cell A1 10/8/2013 Mike1, 2013, 0
now Split(A1,",")
now change A1 and add a colon 10/8/2013 Mike:1, 2013, 0
Split(A1,",") ... notice how Mike:1 is gone. Bug?
I need to split something with a colon in it and it is chopping off part of the text
The problem is that "10/8/2013 Mike:1" is interpreted as a date, it seems to be something like: "dd/mm/yyyy hhhh:mm". (if you change the display of the first cell to raw text you'll see he is giving you a number: 41496).
try this formula:
=arrayformula(SUBSTITUTE(arrayformula(split(REGEXREPLACE(A1;":";"###");","));"###";":"))
in a easier way: As I suppose you can't change the way it's displayed, the possible workaround that I see here is to first split around the ":", then split with the "," and then join the two first elements.
I can't reproduce this issue, either with function SPLIT or with Split text into columns... and with or without formatting as dd/mm/yyyy hhhh:mm.
Select A1, Data > Split text into columns... is all that is required.

Resources