IS NOT NULL - A simple google sheets query issue - google-sheets

I want my google sheets query to just filter out the rows with a blank value and possibly the ones containing specific words as well
Here's an example spreadsheet, I've tried using "where B is not null" in the query but it's not working! I'm tearing my hair out over this as i'm sure it's a simple solution.
https://docs.google.com/spreadsheets/d/1xZH1MKeqLa8r1gRGL9wYHEWe02wQoNNpqqL_ca1fGf0/edit?usp=sharing
Thanks in advance for your help!

you may need to test for empty string instead of null, you can add AND to remove other values:
=QUERY(A2:B6,"select A, B where B<>'Pizza' and B<>''")

This just worked for me
=QUERY(A2:B6,"select A, B where B!='' ",0)

Related

Import Range Query not importing data

Sorry I know this question has been asked before - I have tried changing my query around but can't seem to get it to work as expected, doesn't look to be anything wrong..
I am simply trying to query data from one large master sheet into a few separate sheets. I am using importrange to get the data from sheet, and a simple select query to filter by one of the columns. If I do a select * I get all the data as expected, but can't use a WHERE clause with any column (I just need 1 of the columns, but I tried with a few different ones).
Appreciate any help!
Query:
=QUERY(IMPORTRANGE("1sNA9u2uQW-XjEKjrVS2a5LtTPCchwSuTkXfjhTJtvPk","Sheet1!B:I"),"select * WHERE 'Rank'='LTC' ")
Columns
Username Rank Time In Service TIS Time In Grade TIG Promotable Awards PLT/SQD
Source sheet: https://docs.google.com/spreadsheets/d/1sNA9u2uQW-XjEKjrVS2a5LtTPCchwSuTkXfjhTJtvPk
Test sheet: https://docs.google.com/spreadsheets/d/1UCucsfE0M4j95d_47iN0LrAhS0luv8wXVMHRVTHJHRQ
As player0 stated, you should refer to the columns by its number, you can select multiple columns and state multiple "where" statements by using Col1,Col2, etc respectively. In this case: Where Col2 = 'LTZ'
try:
=QUERY({IMPORTRANGE("1sNA9u2uQW-XjEKjrVS2a5LtTPCchwSuTkXfjhTJtvPk", "Sheet1!B:I")},
"where Col1='LTC' ", )

Google Sheets QUERY IMPORTRANGE formula

enter link description hereI'm trying to get a return of all Active jobs but I keep getting the error message #value!; "Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: A". Here is the formula I used.
=QUERY({IMPORTRANGE("SheetKey","employeeName1!A18:V1000"); IMPORTRANGE("SheetKey","employeeName2!A19:V1000");IMPORTRANGE("SheetKey","employeeName3!A19:V1000");IMPORTRANGE("SheetKey","employeeName4!A19:V1000")},"SELECT A, B, C, D, E WHERE E = 'Active'")
I tried replicating your issue by making a copy of your provided sample sheet but apparently, the formula works after making a copy of the sheet. Please see attached screenshot.
I suggest trying to copy it first making a new sheet with the same content and see if it will also solve your problem.
use:
=QUERY({
IMPORTRANGE("SheetKey", "employeeName1!A18:V1000");
IMPORTRANGE("SheetKey", "employeeName2!A19:V1000");
IMPORTRANGE("SheetKey", "employeeName3!A19:V1000");
IMPORTRANGE("SheetKey", "employeeName4!A19:V1000")},
"select Col1,Col2,Col3,Col4,Col5
where Col5 = 'Active'")
I took out the IMPORTRANGE and just used a query formula for the other sheets and it worked perfect. Thanks for the input everybody.

How to create multiple columns using data from the filter function in Google Sheets

I just started using google sheets to help edit tables for a database and I need some help creating a function. In ColumnA, I've got a list of MovieID's, in ColumnB, there is a list of directors, and in ColumnC, there is a list of unique directors from ColumnB. I'm trying to filter the data and create a set of columns where in one, there is the director's name and in the other, there's the movieID that corresponds to a film the director was involved in.
Ive created a function in F2 to find the ids for a director, and I can just drag the formula down (when the data is transposed, and the C2 value will shift to C3, C4....) But, I want the name of the director to be included in the column to the left of the filtered results (like I've manually done in E), but I can't really figure it out, and I'm not entirely sure on how to use the other functions to get it right.
Any help or guidance on how to achieve this would be greatly appreciated!!
Looks like this will solve your issue
=INDEX(QUERY(SPLIT(FLATTEN(
SPLIT(B2:B,", ",0)&"#"&A2:A),"#"),
" where Col2 is not null order by Col1 "))
If on the other hand there is only one name in cell E2 use
=QUERY(ArrayFormula(IFERROR(SPLIT(IF(REGEXMATCH(B2:B,E2),C2&"-"&A2:A,),"-"))),
"where Col1 is not null",0)

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")

What's wrong with this Google Spreadsheets QUERY?

I've been struggling with this Spreadsheets query problem for hours and even after rigorous googling, couldn't figure out what's wrong or how to do this properly. Here's an example of the problem:
=QUERY('Sheet2'!2:3, "select B where A="A2"")
Example Spreadsheet: https://docs.google.com/spreadsheets/d/172kaXIs0-OhWxhvI65OvnfM1jiLt6OdQVrGYDjxf6V8/edit?usp=sharing
What I'm trying to do is pull data from the Sheet2 so that I can also include the A2 cell from Sheet1 in the equation for better automation. I know there's a way to do it but I just can't seem to be able to make it work.
The syntax is two pairs of quotes (each a single and a double) around concatenation with &. Please try:
=QUERY(Sheet2!2:3, "select B where A='"&A2&"' ")
Your version should work if the actual content of A2 were A2.

Resources