I am using an array to store the multiple cities.
I want to iterate over the cites and pass them one by one or as a whole string and pass a regex in the filter option
I am pasting my code below.
import "array"
city_name = ["cityA","cityB","cityC"]
from(bucket: "bucket_name")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "measurement_name")
|> filter(fn: (r) => r["City"] == city_name |> array.map(fn: (x) => ({_value: x})) )
|> filter(fn: (r) => r["_field"] == "field_name")
|> aggregateWindow(every: 1h, fn: first, createEmpty: false)
|> increase()
|> yield(name: "last")
I want to pass each city one by one and calculate the query for the respective city.
I was trying another approach passing all three cities at once like regex.
b = frnd_name |> array.map(fn: (x) => ({
city_name: "/" + x + "/",
city_name2: x + city_name2,
}))
I want to generate the string city_name = /CityA|CityB|CityC/ and pass into the filter option
|> filter(fn: (r) => r["City"] =~ city_name)
@Anaisdg @scott is it possible to do this with an array in flux?
One more help, is it possible in Flux language to get the difference between two arrays and it will return the third array with the difference?
array_a = [1,2,3,4,5]
array_b = [2,4]
result_array = [1,3,5]
Thanks