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

QUERY : WHERE function to fetch rows with values less than or more than zero depending on user entry in another cell [closed]

$
0
0

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:

  1. "> 0"
  2. "< 0"
  3. "= 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.


Viewing all articles
Browse latest Browse all 9782

Trending Articles



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