Google Sheets: VLOOKUP Using Named Range Fails - google-sheets

I'm using Coingecko to get cryptocurrency prices, and update the data using a 1 hourly Trigger. As the IMPORTDATA function often fails (a known issue using Coingecko), I have a second Trigger than copies this data as a 'backup', using CopyPasteType.PASTE_VALUES.
The primary data is Named Range 'Crypto_Data', the backup is 'Crypto_DataBackup', and the cell's formula is:
=iferror( vlookup(F24,"Crypto_Data",2,false), vlookup(F24,"Crypto_DataBackup",2,false) )
However, the vlookup to "Crypto_DataBackup" fails as it "evaluates to an out of bound range". It works AOK if I just substitute the range of the Named Range (CryptoData!M3:W502).
Does anyone have an idea what the problem could be?

but if you like quotation marks use:
=IFERROR(VLOOKUP(F24, INDIRECT("Crypto_Data"), 2, ),
VLOOKUP(F24, INDIRECT("Crypto_DataBackup"), 2, ))
also, why not:
=IFNA(VLOOKUP(F24, {Crypto_Data; Crypto_DataBackup}, 2, ))

As #Sergey pointed out: "The named range does not need to be enclosed in quotation marks. Change your formula like this: vlookup(F24,Crypto_Data,2,false)"

Related

Simplify formula with multiple IFS from the same column of data

All IFS are from the same range CO4:CO53, changing only the value to be searched, considering that there is only one range to search, is there any way to simplify it so that it doesn't get so big?
It is noteworthy that all must be changed to the same value if found.
=ARRAYFORMULA(
IFERROR(
IFS(
CO4:CO53="Out","",
CO4:CO53="Mid","",
CO4:CO53="Early","",
CO4:CO53="Late","",
CO4:CO53="Red","",
CO4:CO53="Yellow","",
CO4:CO53="1","",
CO4:CO53="2","",
CO4:CO53="3","",
CO4:CO53="Disciplinary","",
CO4:CO53=1,"",
CO4:CO53=2,"",
CO4:CO53=3,""
),
'Copy of Top Plantel A'!A2:A51
)
)
See my comment attached to the original post.
However, given only what I can see, you can try this method:
=ArrayFormula(IF(REGEXMATCH(CO4:CO53&"","^(Out|Mid|Early|Late|Red|Yellow|1|2|3|Disciplinary)$"),,'Copy of Top Plantel A'!A2:A51))
REGEXMATCH returns TRUE (if a match is found) or FALSE if not.
The pipe symbol acts as OR.
A space is appended to CO4:CO53 to convert the numbers 1, 2, 3 to strings (necessary for use with REGEX-type functions).
If the formula as written does not work as expected, please do share a link to the spreadsheet (or a copy of it), with permissions set to "Anyone with the link..." and "Editor."

How to integrate GOOGLEFINANCE results in an array formula?

Following ARRAYFORMULA is giving me an error "parameter 1 value is invalid."
=ARRAYFORMULA(IF(ISBLANK(B2:B), "", GOOGLEFINANCE(B2:B, "price")))
B column of my sheet contains the stock symbols whose value I wish to fill in my sheet. Example below
Company Name
GOOG
ADBE
MSFT
Can someone help here?
This questions seems to be a duplicate of Google finance as an argument for ArrayFormula. I have answered it with more detail. As a new user I'm only able to post an answer here, I cannot comment/flag as duplicate.
Anyway, assuming stock symbols are in range B2:B, then you put the following formula in cell C2:
=IFERROR(MAP(B2:B,LAMBDA(company,GOOGLEFINANCE(company,"price"))))
This is a new method since the introduction of LAMBDA and its helper functions in Google Sheets in August 2022.
The trick here is, as far as I understand, that MAP(LAMBDA) calculates the specified formula for each row in the input array separately (effect similar to manually expanding the formula over the whole range), whereas ARRAYFORMULA passes the whole array as an argument to the formula (GOOGLEFINANCE is special and doesn't work intuitively with such input).
LAMBDA and friends are available, so this works:
=BYROW(A2:A, LAMBDA(row, IF(row = "",, GOOGLEFINANCE(row, "price"))))
Old story:
GOOGLEFINANCE cannot be used in array formulas. You'll have to extend your formula downwards.
For example this formula should be in every cell from C2 and down:
=IF(NOT(ISBLANK($B$2:$B)), GOOGLEFINANCE($B$2:$B, "price"), "")

How to maintain the original header name when performing Google Sheets Query

Hi I have this working query that loops through an arbitrary range of data and produces the results I need:
=arrayformula(QUERY(Crew!A:DY,"SELECT E,A," & join(",", substitute("Count(`1`)", "1",substitute(address(1, column(Crew!F:DY), 4), "1", ""))) & "GROUP BY E,A", 1))
Unfortunately, this produces Columns that are labeled so:
count 18/12/2017 count 25/12/2017 count 01/01/2018
I need to force a display of the original column name, and if possible, the format, e.g. 18/12/2017 as this will allow me to perform further pivot or group by month type functions
I have experimented with different methods of adding a label at the end of the query, reduced the query to tests of the data without using the arrayformula, and searched through the queryLanguage Docs but all references seem to be related to applying a different text string rather than leaving the column header 'raw'
I suspect the main problem is my inexperience, I don't know the correct terms to search for?
How do I achieve this?
Cheers.
You need to use label construction:
"select ... where ... group by ... label ..."
Reference:
https://developers.google.com/chart/interactive/docs/querylanguage#label
You may get labels text with the formula:
="label "&ArrayFormula(join(", ",substitute("count(`1`) ", "1",substitute(address(1, column(F1:G1), 4), "1", ""))&text(F1:G1," 'dd/mm/yyy'")))
change F1:G1 to your range.
The shorter version of the formula with Regex:
="label "&ArrayFormula(join(", ",REGEXREPLACE(ADDRESS(1,COLUMN(F1:G1),4),"(.*)\d+$","count(`$1`) "&TEXT(F1:G1,"'dd/mm/yyy'"))))

How to refer to column 'BY' in query?

In my Google spreadsheet, i'm using the query function to get data from one sheet onto another. The query looks something like this:
=QUERY('mySheet'!$A$1:100,"select F where "&C$3&"='myValue'")
This works fine until cell C3 has value "BY" (because the word "by" has significance in the query language). I've tried using single quotes, but then the query uses header "BY" instead of column BY and it returns an empty result.
Any ideas on how to work around this?
Put it in backticks.
=sum(QUERY(select `BY` where `BY` is not null limit 7))
This will sum the first 7 values in column BY.
(This was fun to debug. The formula worked in every other column...)
"BY" is a special word. It is present in clause group by
You may use this:
=QUERY({'mySheet'!$A$1:100},"select Col5 where Col"&C$3&"='myValue'", 0)
and paste the column number into C$3
see more info here
BTW you may use function column() to know BY is column 77 or find the right number by header name: =match("column name", 'mySheet'!1:1, 0)

Using arrayformula() like continue with nested if()

My goal is to fill down formula while data exist in an adjacent column.
Here is my original formula:
=index(lookups!$M$2:$M30,match($A3,lookups!$N$2:$N30,0))
This formula works in that results are returned as expected.
I then tried this in the hope of it copying down:
=index(lookups!$M$2:$M30,match($A3:A,lookups!$N$2:$N30,0))
This resulted in #N/A "Did not find value in match"
Then I read this post and looked at the second most voted answer and tried editing my formula to this:
=arrayFormula(index(lookups!$M$2:$M30,match($A3:A,lookups!$N$2:$N30,0)))
This time the formula copy down as I hoped, but with a #VALUE error "Function IF parameter 1 expects boolean values. But 'ADT- Alaska Travel Vendor Activities (Search)' is a text and cannot be coerced to a boolean."
How can I tell sheets to copy the index(Match()) all the way down while data exist in column A?
See if this formula delivers the desired output ?
=ARRAYFORMULA(iferror(vlookup(A3:A, {lookups!$B$2:$B, lookups!$A$2:$A}, 2, 0)))

Resources