Modify and Concatenate in the same formula possible? - arrays

I have a Google spreadsheet with more than 1000 rows of data. Column A has unique ID numbers. Column B has video file names. If possible, I'd like to do the following in a single formula:
Enclose the base filename in square brackets (file extension should not be enclosed).
Concatenate columns A and B.
Output the result to Column C.
See screenshot below.
Is this possible without scripts and in a single formula? I tried the formula below but I get a parse error.
=ARRAYFORMULA(A:A&" ["&(SUBSTITUTE(B:B,.mp4,"]"&".mp4")))
*SUBSTITUTE above means I'm trying to substitute ".mp4" with the closing square bracket.

try:
=ARRAYFORMULA(IFNA(A2:A&" ["&
REGEXEXTRACT(B2:B, "(.+)\.")&"]"&
REGEXEXTRACT(B2:B, "(\..+)")))

or:
=ARRAYFORMULA(A2:A&REGEXREPLACE(B2:B, "(.+)\.", " [$1]."))

Related

Concatenate multiple fields on Oracle NetSuite

I would like to create a workflow to concatenate 3 diferent fields, the first and second ones are list/record's type, and the third and last one is a text field. The problem is that the first and second fields are not recognized at the formula and must be converted, and the formula doesn't work. Does anybody could help me with the correct formula to convert the first and second fields and concatenate all fields?
Note: I'm using the simple formula: concat(field1,field2,field3) and it's not working.
In NetSuite you use || to concatenate fields.
Here are two examples:
Code: {firstname}||{custentity2}||{datecreated}
Result:
Code 'Name:'||{firstname}||' Gender:'||{custentity2}||' Created:'||{datecreated}
Result:

How do I get value of an indirect formula into a format that can go into an array?

My Google Sheet that will be updated over time with new sheets. On my dashboard/master sheet, I can write a simple INDIRECT that will pull information from a cell in the sheets. However, the formula does not replicate its way down the column. I understand that I need to use an ARRAYFORMULA to get the auto formula placement done.
I've tried many ways but the one that I think may get me there is to use CONCAT. My columns look like this:
Event Title [uses a script to pull in the names of all the sheets]
Use an array to get the titles so they pre-poluate down the column so I can use it later: =ARRAYFORMULA(IF(Row(A:A)=1,"Get Title from A",IF(ISBLANK(A:A),"",A:A)))
-- The Event Title is now appearing as plain text in Column B.
I then use CONCAT to write the part of the formula I need to help get the name of the INDIRECT in without using the INDIRECT formula.
=CONCAT("'"&B5&"'"&CHAR(38)&"!"&"""","B2"&"""")
-- This gets me this result: 'Computers 101'&"B2"
At this point, my hope is that I could then use this information ('Computers 101'&"B2") into an ARRAYFORMULA. I used this formula to try and do that:
={"Event Date";ARRAYFORMULA(A6:A+D6:D&"Cat")}
-- I get the answer: 0
The expected value was the date cell (B2) in the Computers 101 sheet. Any ideas how to proceed? I don't know the names of the sheets in advance.
unfortunately, this is not possible within of scope of google sheets formula. if you need ranges from other than the actual sheet you need to use INDIRECT which is not supported under ARRAYFORMULA.
you have 3 options:
hardcode it like: https://stackoverflow.com/a/68446758/5632629 with IFERROR & array of empty cells to match columns of your range
generate formula which will generate your final formula/range as a text string and then use a simple script to convert that string into the valid formula: https://stackoverflow.com/a/61819704/5632629
do it all with scripts

How could we use a formula in query Google sheet

I am unable to figure out how could we use formula within query results. I did not find any solution yet.
Like:
=query(sheet1!A1:Z,"Select A,B,Vlookup(D,sheet1!A1:A,1,false)");
If your range is A1:Z, the column where you can insert the formula without error must be bigger than Z
Sheet formulas do not expect (nor allow) semicola at the end
If D is a string, it should be nested in double quotes
To combine your formulas, you need to combine the quotes correctly, e.g.:
=query(Sheet1!A1:Z, CONCATENATE("select A,B,",Vlookup("D",Sheet1!A1:A,1,false)))
you can't. you need to do:
=ARRAYFORMULA({sheet1!A:B, IFNA(VLOOKUP(D:D, sheet1!A:A, 1, 0))})
and then you can play with query:
=ARRAYFORMULA(QUERY({sheet1!A:B, IFNA(VLOOKUP(D:D, sheet1!A:A, 1, 0))}, "select Col1,Col2,Col3", 0)

Concatenating two columns of text Alphabetically in Excel

I am working with this spreadsheet of airport data.Sorry can't figure out how to format the headers, but first column is Origin IATA, 2nd is Dest IATA, and 3rd if Concatenate Route
Origin IATA, Dest IATA, Concatenate Route
LHR JFK LHR-JFK
JFK LHR JFK-LHR
CAN PEK CAN-PEK
PEK CAN PEK-CAN
JFK LAX JFK-LAX
LHR DXB LHR-DXB
DXB LHR DXB-LHR
Picture version:
Right now, I just have =CONCATENATE(C:C,"-",D:D) as the formula, but I actually need them to concatenate in alphabetical order so I can collapse CAN-PEK as one round trip route.
I found someone with a similar question here: Excel formula to take values from cell range, sort alphabetically and write as a single string
And I tried to modify the code of the accepted answer, but I keep getting errors because I don't know what I'm doing. I also tried VBA code, doing it in access, and many other Stackoverflow solutions, but I am stuck.
Does anyone know how I need to write the code to get it to do what I want?
Thank you!
With Excel one can use mathematical inequalities for text strings in many cases. In C2 put:
=IF(A2<B2,A2&"-"&B2,B2&"-"&A2)
Then copy down
When using a formula, you would need to use your existing formula as a helper column and then add the final column containing the sorted results. The example below has the named range "concat" assigned to the concatenate column and the named range "order" assigned to the sort order column.
Note, if your data is in an Excel structured table, you don't need to use defined names. You can select table column and Excel will insert the proper syntax.
Sort Order Column (column E, copy down)
=COUNTIF(concat,"<="&E2)
Alpha Sorted Column (column F, copy down)
=INDEX(concat,MATCH(ROWS($E$2:E2),order,0))

nested if statment with so many text conditions ERROR

this is my data table
I'm writing this formula in openoffice not excel, that's why you will see ";" instead of ","
my questions is that I'm trying to put the currency of each country's capital name, and I did it but the thing is that I'm unable to make more than 42 conditions!!!!!
Is there another way or another formula can I use???
Here is the formula I did, and it's working
=IF(D3="AMSTERDAM";"EUR";IF(D3="FRANKFURT";"EUR";IF(D3="OSLO";"NOK";IF(D3="COPENHAGEN";"MULTI";IF(D3="ALICANTE";"EUR";IF(D3="BARCELONA";"EUR";IF(D3="BERLIN TXL";"EUR";IF(D3="VILNIUS";"EUR";IF(D3="BRUSSELS";"EUR";IF(D3="CATANIA";"EUR";IF(D3="DUSSELDORF";"EUR";IF(D3="FARO";"EUR";IF(D3="GRAN CANARIA";"EUR";IF(D3="HELSINKI";"EUR";IF(D3="MALAGA";"EUR";IF(D3="MUNICH";"EUR";IF(D3="PARIS CDG";"EUR";IF(D3="RIGA";"EUR";IF(D3="SANTA CRUZ PALMA";"EUR";IF(D3="SEVILLA";"EUR";IF(D3="TENERIFE";"EUR";IF(D3="BUDAPEST";"HUF";IF(D3="ANTALYA";"TRY";IF(D3="GAZIPASA";"TRY";IF(D3="ISTANBUL";"TRY";IF(D3="BERGEN";"NOK";IF(D3="STAVANGER";"NOK";IF(D3="STAVANGER VIA ESBJERG";"NOK";IF(D3="LONDON CITY";"GBP";IF(D3="LONDON LHR";"GBP";IF(D3="LONDON STN";"GBP";IF(D3="MANCHESTER";"GBP";IF(D3="FUERTEVENTURA";"ISK";IF(D3="LANZAROTE";"ISK";IF(D3="PORTO SANTO";"ISK";IF(D3="GLASGOW";"SCP";IF(D3="GDANSK";"PLN";IF(D3="CLUJ­NAPOCA";"RON";IF(D3="STOCKHOLM";"SEK";IF(D3="PRAGUE";"CZK";""))))))))))))))))))))))))))))))))))))))))
I'd suggest you use a table in another section of your spreadsheet then use VLOOKUP to match the currency to your country.
=VLOOKUP(D3;Currency_Table;2;FALSE}
Which is lookup D3 in the table named Currency_Table and return the exact match (from FALSE) in the second column which will give you your currency.
Or if you want the formula to exist without dependency upon another table you could use something like:
=VLOOKUP(D3;{"AMSTERDAM"\,"EUR";"FRANKFURT"\,"EUR";"OSLO"\,"NOK"; etc...};2;FALSE}
NB: I've added an escape \ before the comma because I'm assuming you are from a language area that uses , as a decimal by your language settings I'm assuming you'll need that in your array for that to work.

Resources