Hi @anjali07
That is indeed tricky and I did not figure it out until recently. One has to format like this in the Flux query:
|> filter(fn: (r) => r["region"] =~ /^${region:regex}$/ )
or if using InfluxQL, like this:
...WHERE ("type"::tag = 'Demand' AND "region"::tag =~ /^$region$/) AND ...
Screenshots:
query for above:
from(bucket: "EIAtest7")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "ElectricPowerOperations")
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r["type"] == "Demand")
|> filter(fn: (r) => r["region"] =~ /^${region:regex}$/ )
|> group(columns: ["region", "_measurement"], mode:"by")
|> aggregateWindow(every: v.windowPeriod, fn: sum, createEmpty: false)
|> yield(name: "HourlyData")
and in InfluxQL:
SELECT sum("value") FROM "ElectricPowerOperations" WHERE ("type"::tag = 'Demand' AND "region"::tag =~ /^$region$/) AND $timeFilter GROUP BY region, time($__interval) fill(previous)