I am trying to do something that seems like a simple use case, but can’t get the Script Editor (or the Query Builder, for that matter) to show the data I’m trying to look for.
I am trying to group by a tag value, in my case a clientID tag that my data points all have. From there, I am trying to count the number of clients I have for a given time period so I can get some insight into how many unique clients are reporting data. In short: I’m trying to get a count of unique values for a given tag over a time range.
An example from my bucket:
Running this query:
from(bucket: "brawnfire")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> group(columns: ["clientID"])
|> count(column: "_value")
I get the expected result (I can only post one image, so text will have to do – I’ve removed some of the clutter for brevity)
table | clientID | _value
0 | 201ae4c5-3e90-4379-a680-ac0e852ef54a | 1
1 | 2022f5c1-9d22-4fea-8ba9-6164321ffcb1 | 4
Which shows that there are two unique clientID’s, with one having 1 data point, and the other having 4 data points. I haven’t quite wrapped my head around why they show as separate tables (0, and 1)
But from here, I want to boil this down so I can display that there are just 2 clientID’s (either to show as a single stat, or as a graph so I can visualize the unique client count over time.
My attempts have taken me a few directions, but the query below seems to be the closest:
from(bucket: "brawnfire")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> group(columns: ["clientID"])
|> count(column: "_value")
|> count()
|> sum(column: "_value")
By adding a second count, each of the two rows gets a value of 1, but the sum() doesn’t appear to change anything (i.e. the result table looks exactly the same with/without the final sum() function call)
Any direction or advice here would be greatly appreciated as this doesn’t seem like something strange that I’m trying to do.
Thanks for reading!