Hi,
I have a string that I want to use as input ids but my method doesn’t seem to work. First I separate the string into the different id strings that I need and then I try to use these separated strings for the id.
inputID = “1,2,3,4”
_ID = array.from(rows: [{value: inputID}])
|> map(fn: ® => {
parts = strings.split(v: r.value, t: “,”)
return if length(arr: parts) > 3 then
{first: parts[0], second: parts[1], third: parts[2], fourth: parts[3]}
else if length(arr: parts) > 2 then {first: parts[0], second: parts[1], third: parts[2], fourth: “”}
else if length(arr: parts) > 1 then {first: parts[0], second: parts[1], third: “”, fourth: “”}
else if length(arr: parts) > 0 then {first: parts[0], second: “”, third: “”, fourth: “”}
else {first: parts[0], second: “”, third: “”, fourth: “”}
})
ID1 = _ID[0]
ID2 = _ID[1]
ID3 = _ID[2]
ID4 = _ID[3]
from(bucket: “Bucket1”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: ® => r["_measurement"] == “measurement1”)
|> filter(fn: ® => r[“id”] == ID1 or r[“id”] == ID2 or r[“id”] == ID3 or r[“id”] == ID4)
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
|> group()
|> yield(name: “last”)
An other problem is that the length of the inputID string is not always four different id strings. It can be more or less. Is there a way to write a for loop that can account for this difference in length?