This is my QUERY statement:
query(UTrades!A3:Q994,"Select A, C, D, E, F, G, H, I, J, M, Q WHERE (A <> '' or A is not null) and ((C <> '' or C is not null) and (G<>'' or G is not null) and M < 0) ORDER by G", 1)`
This query is fetching data perfectly. In this, M contains the Amount column, which can be negative (Loss) or positive (Profit). The idea is that I want to list out all loss-making rows or profit-making rows.
In this query, where I have M < 0, I want to make it dynamic depending on what the user chooses in another cell like H2. The choices are:
- "> 0"
- "< 0"
- "= 1000" (or any entered amount)
I tried this:
query(UTrades!A3:Q994,"Select A, C, D, E, F, G, H, I, J, M, Q WHERE (A <> '' or A is not null) and ((C <> '' or C is not null) and (G<>'' or G is not null) and M & " " & H2) ORDER by G", 1)`
where H2 may contain ">0" or "<0" or "=1000". I am getting an error.