@Bitdecay Each table in a stream of tables is defined by a group key. The group key is a list of columns for which all values for that column in the table are the same. So when you group by clientID
, you have an individual table for each unique client ID. So to count the number of unique tag values (or clientID
s in this case), what you can do is group by that tag, then use an aggregate function to reduce each table to a single row (like you’ve already done with count()
), then ungroup the tables (or group by nothing), and run the count()
aggregate again. This will give you the number of unique tag values in your returned data.
In the example below, I use limit(n:1)
to reduce the number of rows in each table to one because it’s less “expensive” than an aggregate function.
from(bucket: "brawnfire")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> group(columns: ["clientID"])
|> limit(n:1)
|> group()
|> count()