Splitting Text and Formatting it - Google Sheets - google-sheets

I have a log file with three fields, the first two are userIDs and the third is an item description. Can I use a single formula to Split the text, format the first 2 items, and leave the 3rd alone?
Sample Data:
<#!9812391203019>; <#!98120319283> ; Short Description
Formula Currently used:
=ARRAYFORMULA(REGEXEXTRACT(TRIM(SPLIT(A3,";")),"[0-9]+"))
This works to extract the userID from the unneeded in the first two columns but will only give me numbers for the third.
Previous Formula was within the REGEXEXTRACT but it left the unneeded "<#!" and ">" in the columns which I wanted to remove.
Any help and suggestions would be appreciated! Thanks in advance!

Does this work?
=Split(RegexReplace(A1,"[<#!>]",),"; ",0)

try:
=INDEX(IFERROR(REGEXREPLACE(TRIM(SPLIT(A1:A5, ";")), "[#!<>]", )))

Related

Can I use an arrayformula with a split arrayformula inside it?

Trying to break apart rows containing numbers like "198,183,158,315,274" by their comma, and then average them out and divide them by a singular number; using arrayformula. It only produces one row of result and it's incorrect though?
Here is my test sheet, editable
Thanks for any help.
try:
=ARRAYFORMULA({"Average"; IF(A4:A="",,
IFNA((MMULT(1*IFERROR(SPLIT(INDIRECT("A4:A"&
MAX(IF(A4:A="",,ROW(A4:A)))), ",")),
ROW(INDIRECT("A1:A"&COLUMNS(SPLIT(A4:A, ","))))^0)/
(1+LEN(REGEXREPLACE(A4:A&"", "[0-9\. ]", ))))/B1))})
spreadsheet demo
Another solution:
=ArrayFormula({"Average";(ArrayFormula(mmult(N(array_constrain(ArrayFormula(IFERROR(SPLIT(A4:A8,","))),MATCH(2,1/(A4:A8<>""),1),5)),sequence(Columns(ArrayFormula(IFERROR(SPLIT(A4:A8,",")))),1)^0)/mmult(N(array_constrain(if(ArrayFormula(IFERROR(SPLIT(A4:A8,",")))>0,1,0),MATCH(2,1/(A4:A8<>""),1),5)),sequence(columns(ArrayFormula(IFERROR(SPLIT(A4:A8,",")))),1)^0)))/$B$1})

Filter a string based on a variable number of substrings in Google Sheets

I have a cell with a variable number of substrings separated by a comma.
To search:
"first,second,third"
"primero,segundo,tercero,cuarto"
"eins,zwei"
and I have a column with many strings that are composed by some of the substrings:
Column with full items
"first,second,third,fourth"
"primero,segundo,tercero,cuarto,quinto"
"primero,tercero,cuarto"
"eins,zwei,drei"
...and so on...
I would like to find the items of the Column above which has the substrings to be searched. Not a big issue when the amount of substrings is fixed but when it varies it becomes harder. I have a horrible formula that counts the number of commas and then it uses IF for each amount of substrings to search and several FIND(index(SPLIT(A4,","),2) for each substring. The formula is gigant and hard to handle.
Can you think of a better way of doing it?
Here there is an example of what I would like to do. The blue cells are the ones that should have the formula.
https://docs.google.com/spreadsheets/d/1pD9r4JF48cVSNGqA4D69lSyasWxTvAcOhWWu1xW2mgw/edit?usp=sharing
Thanks in advance!
Thank you all for your help! In the end, I used the QUERY function.
=QUERY(E:F,"select E where F contains '" & textjoin("' AND F contains '",TRUE,split(A2,",")) &"'" )
If you are interested, you can see the solution applied in the original spreadsheet :)

How can I search a column with alphanumeric entries and return a 1 for unique with an array formula?

I need something that auto-fills for however many rows are in the spreadsheet, but I'm not sure if an array is the best way.
In my example below, I want Column C to show a 1 if the corresponding entry in Column A is unique, and a 0 if it isn't.
I had hoped it would be as easy as using ARRAYFORMULA(IF(UNIQUE(A1:A),1,0)), but forgot that IF wouldn't work with the text.
Here's my example with the most recent formula I tried.
Thank you!
Please use the following formula:
=ArrayFormula(IF(LEN(A1:A)<>0,
IF(COUNTIF(A1:A,A1:A)>1,0,1)
,""))
Functions used:
COUNTIF
ArrayFormula
LEN
You can combine ARRAYFORMULA and IF with IFERROR and COUNTIF
Sample:
=ARRAYFORMULA(IF(IFERROR(COUNTIF(A1:A,A1:A)=1,0)=TRUE,1,0))

Q: Transpose -> Merge(?) on google sheets

Trying to transpose data such that rows transpose into a single column stacking on top of each other.
=ARRAYFORMULA({TRANSPOSE(A1:C1);TRANSPOSE(A2:C2);TRANSPOSE(A3:C3)})
This formula essentially does what I want but what if I have many more rows? Would I need to enter; TRANSPOSE(Col(x):Col(y)) for every single row?
Any help is appreciated.
Please try:
=TRANSPOSE(SPLIT(TEXTJOIN(",",1,A:C),","))
Notes:
textjoin will join text and skip blanks. Add spaces in column C to have an empty row.
limit of join function is 50000 characters
Max Makhrov's answer is good, but indeed subject to the 50k limit. To get around that, I have recently found another method which is explained in my
interlacing answer to another question
In your case this would look something like this (up to arbitrary 9 rows):
=query(
sort(
{arrayformula({row(A1:A9)*3, A1:A9});
arrayformula({row(B1:B9)*3+1, B1:B9});
arrayformula({row(C1:C9)*3+2, C1:C9})}
),
"select Col2")
Am I missing something, or why does nobody suggest Flatten?
FLATTEN(A1:C3)
And you can use Filter as usual to filter out blank cells, e.g.
=FILTER(FLATTEN(A1:C3);FLATTEN(A1:C3)<>"")

Find Unique in google sheets - first n characters

I have a google sheet with a column (A) of urls.
Xttps://tXco/008wnbebbw
Xttps://tXco/00lR1FNKBo
Xttps://tXco/00lR1Fw9cO
Xttps://tXco/00UwZwgh2h
Xttps://tXco/00UwZwxSqR
Xttps://tXco/00UwZwxSqR
Xttps://tXco/044TcIFl72
In column B I need to find all unique urls up to the 18th character. For instance column B should show:
Xttps://tXco/008wnbebbw
Xttps://tXco/00lR1FNKBo
Xttps://tXco/00UwZwgh2h
Xttps://tXco/044TcIFl72
I have this formula which I was trying to adapt for it (not sure if it helps at all). I was trying to adapt this to use with =UNIQUE( ?
=SUMPRODUCT(--(LEFT($A$1:$A$15,18)=LEFT(A1,18)))>1
If it helps to take a look at the sheet, here it is: https://docs.google.com/spreadsheets/d/1tG7TpHNvNY86PRiePsKyKfxnuEZah6T7ZDL7dXOIcEA/edit?usp=sharing
Thanks in advance!
You may try this formula:
=ArrayFormula(vlookup(
UNIQUE(FILTER(LEFT(A2:A,17),A2:A<>"")),
FILTER({LEFT(A2:A,17),A2:A},A2:A<>""),
2,0))
How it works
it will first find unique left N chars:
UNIQUE(FILTER(LEFT(A2:A,17),A2:A<>"")
then get left N chars and original strings:
FILTER({LEFT(A2:A,17),A2:A},A2:A<>"")
and then use vlookup to get top first entry for uniques.
Try this instead without the extra column. Put it in B1:
=unique(arrayformula(if(left(A1:A,18)=left(A1:A,18),A1:A,"")))
Try this: =unique(arrayformula(left(A1:A,18)))

Resources