InfluxDB query for Boolean Tag

Dear team:

I want to test one use case which is explain here:

I have three bool vriables and wanted to fetch them from InfluxQL time series database.
I want to fetch all three data from measurement and display on dashboard like if one of the data is TRUE then display 1 on dashboard otherwise display FALSE on dashboard.

My query is below :
SELECT last(“value”) FROM “database” WHERE (“tag” = ‘PC_1’ OR “tag”= ‘PC_2’ OR “tag” = ‘PC_3’) AND $timeFilter GROUP BY “tag”::tag ORDER BY time DESC LIMIT 1

My questions are :

  1. does this possible to perform using InfluxQL language in grafana?
  2. can we perform “if” and 'else" conditions in query?
  3. to achieve my solution is there any workaround?

I tried with multiple way but its nor working please help.

THANK YOU!!

~ the grafana team

1 Like

Please do reply as i’m stuck with this issue.

InfluxQL itself doesn’t have direct conditional statements like “if” and “else.” However, you can achieve similar functionality using Grafana’s Templating or transformation features.