Adding thresholds to table panel created using flux language

Hello,

Problem: I created a table using flux. When I go to “Add Threshold” colors do not show up.

What I expected: I expect that when I go to “Override 1” and select the column “uptime”, I can add thresholds there and they will show up in colors on my table. They are not showing up even though it shows up as a field. (See screenshot)

Code:

[quote=“celeste, post:5, topic:137750, full:true”]

collectionInterval = 60s
pointsPerMinute = float(v: 1) // Ensure this is a float for consistency

data = from(bucket: “bucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._field == “data”)

// Calculate counts of non-NaN values and expected points
|> reduce(
identity: {count_exists: 0.0, count_expected: 0.0}, // Initialize fields as floats
fn: (r, accumulator) => ({
count_exists: if exists r._value then accumulator.count_exists + 1.0 else accumulator.count_exists,
count_expected: float(v: (uint(v: v.timeRangeStop) - uint(v: v.timeRangeStart))) / 60000000000.0 * pointsPerMinute // Total expected points
})
)

// Calculate uptime percentage and add device_id as _time
|> map(fn: (r) => ({
r with
test: (float(v: r.count_exists) / float(v: r.count_expected)) * 100.0, // Direct float division
//test: r.count_exists,
_time: r.device_id // Replace _time with device_id for display
}))
|> keep(columns: [“_time”, “_field”, “test”]) // Keep only relevant columns

// Pivot data using uptime as value
|> pivot(rowKey: [“_time”], columnKey: [“_field”], valueColumn: “test”)
|> rename(columns: {_time: “device_id”, data: “uptime”})

|> yield(name: “uptime”)

*Pivot is still a little confusing to me but this works

Hi @celeste

Do you have this field selected as shown?

Oh dear. That was the problem. Thank you Grant. :smiling_face_with_tear: