Google Sheet: Reference cell inside importhtml query - google-sheets

I am trying to using the following formula to import a table from ESPN:
=QUERY(IMPORTHTML("http://games.espn.com/ffl/schedule?leagueId=2127","table",2),"SELECT * WHERE Col1 = "&B3&"")
Basically, I only want to return rows that contain the value inside cell B3. However, I am having trouble getting the formula to work. It works fine when I manually type in the value instead of referencing the cell. How can I reference a cell my query?

I was able to solve this by using the below formula instead:
=QUERY(IMPORTHTML("http://games.espn.com/ffl/schedule?leagueId=2127","table",2),"SELECT * WHERE Col1 = '"&$B3&"'")

Related

query not resolving formula

I am trying to concatenate data in QUERY formula from cell as shown in image
(https://i.stack.imgur.com/3EdUX.jpg)
Formula is :=QUERY(CONCATENATE(A9,"!A2:D5"),"Select A,B")
picking data_range from another cell
how can I get it?
picking "data_range" from another cell
I want to "data_range" in query changeable
use:
=QUERY(INDIRECT(A9&"!A2:D5"); "select Col1,Col2"; )

Reference a sheet range dynamically inside formula by using a cell value

How can I reference a sheet range by using a cell value?
i.e
This is a working formula
=filter(dump!1:1000,dump!G:G = "Active")
However, I need to reference the sheet's G:G range dynamically by using a cell value.
Let's assume my cell A1 contains "G:G" as the value inside it.
My formula would be something like
=filter(dump!1:1000,"dump!"&A2 = "Active")
..but of course it doesn't work because I'm not using the syntax properly.
use:
=FILTER(dump!1:1000, INDIRECT("dump!"&A1) = "Active")
but keep in mind that G:G needs to have exactly 1000 rows otherwise you will face ARRAY_ error
Use INDIRECT:
=filter(dump!1:1000,"dump!"&INDIRECT(A1) = "Active")

modify number from cell reference in QUERY function (Google Sheets)

Is it possible to modify a number from a cell reference within the syntax of a QUERY function in Google Sheets without a helper cell/column?
If I have "5" in a cell, can I reference that cell and somehow subtract 1 when using the LIMIT option in the QUERY syntax so it returns four results?
I am including a sample sheet below as well as working and nonworking formulas.
link to sheet & cell
https://docs.google.com/spreadsheets/d/1lyCK5eIEQYjGFOxh5T_4BxeuDS-1zvMLq80IYn0dc38/edit#gid=1018697126&range=B1
working formula:
=QUERY(INDIRECT(currentTable),"limit "&B1&"",1)
nonworking attempt:
=QUERY(INDIRECT(currentTable),"limit "&B1&"-1",1)
You can just subtract 1 from B1 instead before passing it into the query.
=QUERY(INDIRECT(currentTable),"limit "&B1-1,1)
Output:

Using array formula and countif to lookup based on specific cells

I'm trying to embed a countif into an array formula in Google Sheets. I'm using the countif command to count the number of cells on another page with a given text string, stored in column B. Column B just contains a list of titles. The concatenate portion does a general keyword lookup.
Here is the formula that does not work. It just returns a 0 in each cell, which tells me the countif statement is failing.
=arrayformula(IF(B2:B<>"",COUNTIF(Registrations!C:C,(CONCATENATE("*", B2, "*"))),""))
If I pull out the countif statement, it works fine by itself.
=COUNTIF(Registrations!C:C,(CONCATENATE("*", B2, "*")))
I have even tried referencing B2:B in place of the B2 cell reference, but that does not work. What did I do wrong in the array formula statement?
Have you tried using & instead of the CONCATENATE function and referencing to B2:B in place of only B2?
The formula should look like this:
=arrayformula(IF(B2:B<>"",COUNTIF(Registrations!C:C,("*" & B2:B & "*")),""))
It works for me.
This is my 'Registrations' sheet:
And this is the sheet where the formula is written:

How to use absolute references in google sheets query formula or query by column names for multiple sheets?

I have the following problem. I'm trying to write query formula in order to put all values in one sheet by typing yes in one column, however, I have the following problem. Whenever I add a new column, references in query formula (multiple sheets) are changing and the formula doesn't work. How can I prevent this?
Or is there any way to query by a column name in multiple sheets?
I have tried locking relative references by putting sign $
I have tried to use an indirect formula to take references (data set in Helper TAB, cell E2) - nothing worked
I'm out of the ideas, for now, anyone knows how to fix this?
=QUERY({'Sheet 1'!$A:$Z;'Sheet 2'!$A:$Z;'Sheet 3'!$A:$Z;'Sheet 4'!$A:$Z}, "select * where Col1 ='yes'",0)
Here is the file I did, you can see query formula in Master sheet:
https://docs.google.com/spreadsheets/d/1XD-CECy5W5-HM5EkBFJQKDtLlykQq8Cj8ZOvDUXkd1s/edit?usp=sharing
A solution to the problem is to use a formula that searches for the column address based on a reference.
=SUBSTITUTE(ADDRESS(1;COLUMN(A1);4);"1";"")
This formula will return the value A, which is the column of address A1.
It can be used in query functions like this:
=QUERY(A:D;"SELECT "&SUBSTITUTE(ADDRESS(1;COLUMN(A1);4);"1";"")&"")
This function is equivalent to the function:
=QUERY(A:D;"SELECT A")

Resources