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

Combine two separate, working queries

$
0
0

Trying to combine two separate, working queries, so both can be used on a single sheet.

The idea is a User selects Data for a Resource (sheet TAB), and then either: a Region (Column D) or a County (Column H). Both Region and County are Drop Down lists.

These are the Queries that work separately:

=QUERY(indirect(B2&"!A1:H20"), "SELECT * WHERE 1=1 " &IF(A2="All Counties", "", " AND (D) = '"&A2&"' OR (D) = 'All Counties'"),3)

=QUERY(indirect(B2&"!A1:H20"), "SELECT * WHERE 1=1 " &IF(C2="All Regions", "", " AND (H) = '"&C2&"' OR (H) = 'All Regions'"),3)

Working Queries are on the first 2 TABs of this sheet

I have tried to join them:
={QUERY(indirect(B2&"!A1:H20"), "SELECT * WHERE 1=1 " &IF(A2="All Counties", "", " AND (D) = '"&A2&"' OR (D) = 'All Counties'"),3); QUERY(indirect(B2&"!A1:H20"), "SELECT * WHERE 1=1 " &IF(C2="All Regions", "", " AND (H) = '"&C2&"' OR (H) = 'All Regions'"),3)}

Also tried a few things like this with various syntax changes:
=QUERY(indirect(B2&"!A1:H20"), "SELECT * WHERE 1=1 " &IF(A2="All Counties", "", " AND (D) = '"&A2&"' AND (C2)="-" OR (D) = 'All Counties'" AND (C2)="-" OR C2="All Regions", "", " AND (H) = '"&C2&"' AND (A2)="-" OR (H) = 'All Regions' AND (A2)="-" "),3)

Also tried similar to above, but used ISBLANK(C2) type syntax.


Viewing all articles
Browse latest Browse all 9843

Trending Articles



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