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","")))
Related
I am currently working on a dataset that includes several columns, mostly the dates. What I am trying to achieve is - unpivot all the date columns to use for my subsequent calculations. I use the following formula to unpivot: =ARRAYFORMULA(SPLIT(FLATTEN(Data!A2:A&"|"&Data!D1:AG1&"|"&Data!D2:AG),"|"))
Even though this returns the expected result, when I try to nest this within a Query function, it does not work correctly. This is how I applied the formula - QUERY(ARRAYFORMULA(SPLIT(FLATTEN(Data!A2:A&"|"&Data!D1:AG1&"|"&Data!D2:AG),"|")),"Select * WHERE Col3 IS NOT NULL")
PS: When I change the data range to say, A2:A100, it gives me the correct result. However, it does not help since lot of new data would get added and I want the formula to be dynamic.
Here's the link to the sample sheet - https://docs.google.com/spreadsheets/d/1dgFY5mT9nUJtFefjAros-XpWXRMFtxEf8Fqrv82N5Ys/edit#gid=1813140523
Any help/suggestions would be highly appreciated
Not sure where you got your SPLIT(FLATTEN technique,
but you have to include both the 3rd and 4th parameters of the split function as FALSE or 0. so in your case it would be:
=ARRAYFORMULA(SPLIT(FLATTEN(Data!A2:A&"|"&Data!D1:AG1&"|"&Data!D2:AG),"|",0,0))
If you do that you'll find your query works.
Also note that the way you have it it's not really working. If you look all the way down in column 1 you'll find a bunch of dates formatted to look like integers.
I'm creating a crypto tracking spreadsheet and I'm getting some strange results using the LOOKUP function.
I have two named ranges:
The symbol range is called USDCoinSymbols
and the coin name range is called USDCoinNames
Here are some function results when I try using the LOOKUP function:
Apologies for the mixed casing on the search term. I was experimenting, but
it seems the LOOKUP function isn't case sensitive (for example, BNB returned the correct coin name).
I also tried the inverse, looking up a coin symbol with a coin name (2nd result) and that works fine.
I spent a good couple hours trying to figure this out.
Am I missing something or is this a bug?
Edit: Here is a link to sample spreadsheet and I'm using the CoinGecko API to get this data.
I'm trying to pull the coin name using the symbol to fill up a table I'm creating.
This is not a bug. It's just how LOOKUP works.
LOOKUP requires that all search-column information be in strict least-to-greatest order, so it wouldn't work with your data.
I've added a new sheet ("Erik Help") which is a duplicate of your first sheet. In my sheet, I deleted your LOOKUP formulas from B20:B27 and replaced them with one array formula. This formula uses VLOOKUP with FALSE as the final parameter, meaning that your data is NOT ordered in strict least-to-greatest order and that exact matches should be searched anywhere instead. This one formula fills all results for B20:B:
=ArrayFormula(IF(A20:A="",,IFERROR(VLOOKUP(A20:A,B2:C14,2,FALSE))))
If you are going to be applying this to a larger list elsewhere and want to use your named ranges, just replace B2:C14 with {USDCoinSymbols, USDCoinNames}.
References:
LOOKUP
VLOOKUP
You will need to use the VLOOKUP function instead
=INDEX(IFERROR(VLOOKUP(A20:A25, {USDCoinSymbols, USDCoinNames},2,0)))
This single formula is all you need.
Since your lists are NOT sorted you should use 0 in the function
(please -as always- adjust formula according to your ranges and locale)
I'm trying to create a Google Sheet formula that searches for a word in a longer string and returns a specific value based on the string being searched.
I can achieve this in Excel but I need this to work in Google Sheets.
Below is an example of what I'm trying to achieve:
The "Sort" column is retrieving the value based on checking if the word in column "C" exists in column "A".
I've tried using wildcard search but this isn't working for me in Google Sheets, and other examples I've seen online don't seem to allow me to return multiple values.
Any help would be much appreciated.
This formula may fit you:
=IFERROR(REGEXEXTRACT(A1,JOIN("|",FILTER(C:C,C:C<>""))),"none")
Here're some useful links:
REGEXEXTRACT
JOIN
FILTER
I have two sheets in my Google spreadsheet, "input" and "output".
On my "input" sheet I have multiple values,
which always have a certain letter in front of them.
On the other sheet "output" I want to add all values together for each letter
and then be able to multiply this result with another value.
The values sometimes are whole numbers, other times they hav decimal places.
I tried the following functions to extract only the number without the letter,
but then the extracted value was not a number that I could continue to use for other math functions such as multiplications.
=REGEXEXTRACT(XX;"[0-9]+")
=REGEXEXTRACT(XX;"[0-9]*\.[0-9]+")
=REGEXEXTRACT(XX; "\d+")
=SUM(SPLIT(XX;CONCATENATE(SPLIT(XX;".0123456789"))))^
If I tried to use "=VALUE(XX)" I got a weird number.
Also this formulars are only for one cell,
but I want the formula to work on the whole "input" sheet.
Therefor it must be used in combination with something like
=SUMIF('input'!A:Z; "XXXX"; 'input'!A:Z)
...at least this is my best guess.
I linked a sample sheet below, can you help me out guys?
Many thanks in advance!
Google Spreadsheet Test
For getting the sum of the cells which have letter "E" at the beginning, try the following formula:
=sum(arrayformula(iferror(regexextract(input!A1:H100,"E ([\d.+]*)")*1)))
In Google spreadsheets, how do I find the sum of two ranges referenced from different spreadsheets
I want to use something like
=(IMPORTRANGE("keyofsheet1","A1:A100")+ IMPORTRANGE("keyofsheet2","A1:A100"))
and get the sum
Apparently, the above doesn't work. Any help would be appreciated :).
I have found an answer:
Arrayformula is what I was looking for. It basically applies the formula treating the range as a range, instead of as a single element. I still donot totally understand why this works. would be really happy if someone could explain this
I just used
ARRAYFORMULA((IMPORTRANGE("keyofsheet1","A1:A100")+IMPORTRANGE("keyofsheet2","A1:A100")))
and suddenly everything works as it should.
Shouldn't the + operator be conscious of the input type it is getting and automatically respond by returning the appropriate type? why do I need to explicitly specify that this is an array formula
I ran into a similar issue yesterday. Solution was:
=SUM(IMPORTRANGE("keyofsheet1","SheetName!A1:A100")) + SUM(IMPORTRANGE("keyofsheet2","SheetName!A1:A100"))
No need to use ARRAYFORMULA()
2 important notes.
You will probably see a #REF! error in your cell with a red color in the corner. You'll need to hover over it and allow access to the spreadsheets that you're referencing.
If any of the original data in the spreadsheet ranges you're referencing in A1:A100 contain errors such as
#NULL!
#DIV/0!
#VALUE!
#REF!
#NAME?
#NUM!
#N/A
then your formula must be modified to include SUMIF() as follows
=SUMIF(IMPORTRANGE("keyofsheet1","SheetName!A1:A100"), ">0") + SUMIF(IMPORTRANGE("keyofsheet2","SheetName!A1:A100"), ">0")
This ensures that it's only adding anumbers and not error codes.