What I've tried...
- Various syntax variations
- Google searches
What I'd like, in simple terms...
=IF(B2=" ",QUERY(RawData!$A$2:$I, "SELECT A,B,C,D,E WHERE H = '"&A3&"'"),QUERY(RawData!$A$2:$I, "SELECT A,B,C,D,E WHERE H = '"&A3&"' AND A = '"&A4&"'"))
In other words, if B2 is blank, return ALL results; otherwise, return results based on the text found in B2.
The formula DOES work if both A3 and A4 have values. It does NOT work if A4 is blank.
I can't share the sheet (gov't data), sorry, but hopefully I've explained the issue clearly enough.
Now I'm thinking that maybe a FILTER function would be better?
Thoughts?
CodePudding user response:
IF
it:
=IF(B2="",
QUERY(RawData!$A$2:$I, "SELECT A,B,C,D,E WHERE 9=9 "&
IF(A3="",," and H = '"&A3&"'")),
QUERY(RawData!$A$2:$I, "SELECT A,B,C,D,E WHERE 9=9 "&
IF(A3="",," and H = '"&A3&"'")&
IF(A4="",," and A = '"&A4&"'")))
CodePudding user response:
Use this formula
=IF(B2="",
QUERY(RawData!$A$2:$I, "SELECT A,B,C,D,E WHERE H = '"&A3&"'"),
QUERY(RawData!$A$2:$I, "SELECT A,B,C,D,E WHERE H = '"&A3&"' AND A = '"&A4&"'"))
Result
1 - When B2
is Empty ""
2 - When B2
is Not Empty