Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9843

Sheets QUERY (Select, Where, Contains, Limit) that works, except when blank cell

$
0
0

I have a Google sheets QUERY formula that pretty much works:

=query(data,"SELECT A WHERE B contains '"& A5 &"' LIMIT 10",1)

Essentially what the query is doing is, for the given data range, it selects a cell from column A where column B contains certain text, and I am limiting the output list of values returned to just 10 rows. That all works fine.

Where I encounter a problem is when the "& A5 &" above references an empty cell, I am still getting a list of values returned (and the wrong ones) when really, if an empty cell is referenced, the output should be nothing at all. So, if the "& A5 &" references an empty cell, I want NO output values returned at all i.e. blank results.

I've done a cursory google search on several different forums for possible solutions. Apparently 'is not null' might be a solution? Or <>'' ? But I'm not sure how to incorporate into the syntax.

Apologies I'm not a sheets/query/syntax expert and would be grateful for advice/suggestions.


Viewing all articles
Browse latest Browse all 9843

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>