what is a proper way (fastest solution) to define variable in settings that will contain unique tag values of measurement,
in range v.timeRangeStart, v.timeRangeStop
Hello @va2dim, schema.measurementTagValues() doesn’t support the v.timeRangeStart and v.timeRangeStop parameters in the way you expect because it retrieves all unique tag values across the entire measurement, not just within a specific time range.
Try this:
import "experimental/array"
// Filter the measurement by the time range and then extract unique tag values for the tag "path"
routePatterns = from(bucket: v.bucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "user_timing")
|> keep(columns: ["path"]) // Keep only the tag column
|> group() // Group the data to eliminate duplicates
|> distinct(column: "path") // Get unique tag values
// Add "All" value manually
allStream = array.from(rows: [{_value: "All"}])
// Combine "All" with the distinct tag values
filteredRoutePatternsWithAll = union(tables: [allStream, routePatterns])
filteredRoutePatternsWithAll
Thanks @Anaisdg ,
I need (array) routePatterns not only as dashboard variable v.path (to filter my dataset), but also
in my query to use it for array.map purpose (for option “All”).
I am interesting in some way to extract list/array of all possible option of this dashboard variable (to not duplicate & execute same logic twice). Please guide, exist some possibility to do this?