I have a list of IDs like this :
40316C1
40316433D112
4316C1
4Z2
40316B2
40310
I would like to return the IDs like this:
40316
40316433
4316
4
40316
40310
Basically, from the first alphabet Character, Trim or Split the rest on the right.
Can I do this in Google Sheets?
You can do it with REGEXEXTRACT
Sample:
=REGEXEXTRACT(A1,"\d{1,20}")
This formula will evaluate the first 20 characters of the IDS (you can change 20 to ahigher number if necessary`
\d means that the formula will extract only numbers from the IDs - until it finds the first non-number.
UPDATE:
The case of no text characters existing in the cell can be caught with =IFERROR
=IFERROR(REGEXEXTRACT(A5,"\d{1,20}"),A5)+0
Related
I'm struggling with writing the proper syntax for this formula in Google Sheets. In one sheet called Game Log, in the H column I have data that can be a range of names (1 - 10 names per row). I'm trying to construct a COUNTIF statement that would search for the name in all the rows for that column. There can be several other names in the same column so I need to use the wildcard * to find any occurrence of the name in each row. So for example, the current code below would count all occurrence of Adam in the rows.
=COUNTIF('Game Log'!H3:H102, "*Adam*")
What I would like to do is replace the hard codes "Adam" with a cell reference (in this case B2). Is it possible to combine that cell reference with the wild card? The know the code below doesn't work (as it would return text counting occurrences of B2), but is something like this possible?
=COUNTIF('Game Log'!H3:H102, "*B2*")
Have you tried something like this?
=COUNTIF('Game Log'!H3:H102, "*" & B2 & "*")
That ought to look for any string value, followed by the cell value, followed again by any string value. It's essentially just performing separate checks, in sequence, which allows you to search for different value types (in this case string wildcard + cell value + string wildcard).
Hi everyone,
I have 2 google sheets with data as shown in the screenshot above. For the first google sheet, the empty row are row 3 & row 7. For the second google sheet, the empty row are row 2, row 7 and row 10. I want to combine these two google sheets in a master google sheet. This is what I used to combine the data and the result that I get:
=QUERY({IMPORTRANGE("1BT3KLMGoE3FMaiW8G1ig6GRTyaJnYcskSaIeki7m-gs","Sheet1!A1:J100"),IMPORTRANGE("1gW5rEiinQe-PaqvFH890ZXXx7YnSVtmUghhpTl7lGng","Sheet1!A1:J100")},"where Col2 is not null")
As you can see, the data from second google sheet start from Column K and row 3 data is missing. I want to start the data from second google sheet in row 9 instead of Column K. May I know what I did wrong in the QUERY and IMPORTRANGE and how to avoid missing the data from second google sheet (row 3 data)?
Hope to get some helps and advices, thank you.
Issue:
As per kishkin's comment,
Try replacing comma , before the 2nd IMPORTRANGE with semi-colon
Formula:
=QUERY({IMPORTRANGE("1BT3KLMGoE3FMaiW8G1ig6GRTyaJnYcskSaIeki7m-gs","Sheet1!A1:J100");IMPORTRANGE("1gW5rEiinQe-PaqvFH890ZXXx7YnSVtmUghhpTl7lGng","Sheet1!A1:J100")},"where Col2 is not null")
Delimiter used is , instead of ;. I assume you are located most likely in Europe and that is the reason of the issue. See reason below.
Reason:
Locations using decimal points:
For locations using periods (or points or dots or whatever you call them) to denote decimal separators (most non-European countries including US, UK, Australia), the syntax will follow this structure:
Decimals will be denoted by a decimal point (a period)
Arguments in formulas separated by a comma
Horizontal data in curly-brace arrays separated by a comma
Locations using decimal commas:
For locations using commas to denote decimal separators (most European countries), the syntax will follow this structure:
Decimals will be denoted by a comma
Arguments in formulas separated by a semi-colon
Horizontal data in curly-brace arrays separated by a back-slash
Output:
Reference:
Sheets Location
This a simple customer sheet:
A B C D
ID First Middle Last
1 John Doe
2 Jane Maia Doe
And in F1 I put this vlookup code:
=VLOOKUP($G$1;$A$1:$D$3;2;FALSE)&" "&VLOOKUP($G$1;$A$1:$D$3;3;FALSE)&" "&VLOOKUP($G$1;$A$1:$D$3;4;FALSE)
When I lookup ID 2, it's perfect nicely spaced between the vlookups
But when I lookup ID 1 you see 2 spaces between the first and last name, because there is no middle name here.
How can I manage that I always see 1 space between the vlookups?
One way you could achieve the result you're looking for is to simply replace multiple spaces with a single space.
=REGEXREPLACE(JOIN(" ",ARRAYFORMULA(VLOOKUP(G1,A:D,{2,3,4},FALSE))),"\s{2,}"," ")
This formula looks up G1 in your table (A:D). VLOOKUP can be used in an ARRAYFORMULA to efficiently retrieve all of the columns you want in one shot. Your JOIN joins all of the retrieved columns, inserting a space between each value. Finally, your REGEXREPLACE function looks for multiple consecutive spaces and replaces them with a single space.
Alternatively, you could filter the resulting array (i.e. the result of what your VLOOKUP returns). The following formula looks up the array of first, middle, and last name, and then filters out any empty cells before joining the remaining elements with a space.
=JOIN(" ",FILTER(VLOOKUP(I1,A:D,{2,3,4},FALSE),INDIRECT("B"&MATCH(I1,A:A,0)&":D"&MATCH(I1,A:A,0))<>""))
all you need is TRIM fx and:
=ARRAYFORMULA(TRIM(TRANSPOSE(QUERY(TRANSPOSE(IFERROR(
VLOOKUP(G1:G2, A1:D3, {2,3,4}, 0))),,999^99))))
How do I remove non-numerical characters from a filter in Google Sheets?
I have a function that spits out matching phone numbers into up to 3 subsequent columns. I would like to eliminate non-number characters and a prevailing 1 if there is one, possibly using Regex.
=array_constrain(transpose(filter(People!H:H,People!B:B=A10)),1,3)
=ARRAYFORMULA(IFERROR(REGEXREPLACE(TO_TEXT(A1:A), "\D+|^1", "")))
I'm trying to count number of items in given table. But table may consist cell with different whitespace chars.
I would like to do count, but only consider cell with letters and number.
I was trying to do
COUNTIF(<range>, "?*")
Is there any list of available wildchars provided by google-spreadsheet ? I need "*" but matching only numbers and letters.
Maybe use regexmatch to match letters or digits ?
=ArrayFormula(sum(N(regexmatch(A2:L18&"", "\w|\d"))))
Change the range to suit.
See also this spreadsheet