Query: How to Return Boolean if value(x) above or below (y) value?

Hello, I have a measurement value(x) that varies between 0 and 500. I would like to use a query to return 1 (Boolean) if this value is below a set value(y) for example 200 and 0 if it is above. I Need to do this for a discrete visualisation I want to use.
In SQL server I would use a case statement like

case when col_x < 200 then 1  else  0 end
from <tablename> where <some condition>.

but in Influx since no case statement I have to use a calculation. I have seen another question similar to this where it suggests using floor() but I’m not sure how to do this. Any assistance appreciated

What’s wrong with just “select (x<200) from … where …”?


I’m trying to show on a Discrete control (Grafana) when above or below. This is either true or false. I.e. it shows Green for true Red False. I cant use the actual value.

I don’t understand the problem. “x<200” results in a boolean, true or false.
That’s what you want, right?


Hmm, I musn’t be getting the syntax correct if that works. My measurement is MachineCurrent my value is Current. So you are saying “select (Current1>200) from MachineCurrent” will give me true/false value?

My data

select max(“Current1”) from MachineCurrent
name: MachineCurrent
time max

2019-09-30T11:10:28.173717479Z 381.84

Not sure how what you are suggesting would work.
select (Current1>200) from MachineCurrent
ERR: error parsing query: invalid operator > in SELECT clause at line 1, char 8; operator is intended for WHERE clause