Dashboard timestamp variable

Hello community,

I’m struggling with the next issue and I hope someone will be able to help / guide me in the right direction.

I have a dashboard with several cells, for some cells I need to update the last time a certain action was executed. For instance the last time I refuelled the oil storage tank.

To update this date I every time need to edit the query range start:

from(bucket: "myhomesensors")
  |> range(start: 2021-06-14T00:00:00Z, stop: v.timeRangeStop)

I’m wondering if I can not setup a Dashboard variable instead, I can then have a visual of the last timestamps by making the variables visible and in case of a change I can just edit the new timestamp in the variable instead of in the query.

I’ve tried a lot of different things but without success. I keep receiving errors about ‘stream’, ‘time expected, string returned’ …

Thanks in advance for the help/tips on how I should proceed.


@Chris_Home You can certainly use a dashboard variable to do this. There are a few things to note:

  • There currently isn’t a dashboard variable type that you can easily customize while viewing the dashboard (something like a text field), so you’d have to go in the variables menu to update the value(s) available for this variable.

  • Custom dashboard variable values are always strings. To use a custom dashboard variable as a start value, you need to cast it to a time type:

    from(bucket: "myhomesensors")
        |> range(start: time(v: v.myCustomVariable), stop: v.timeRangeStop)

Thank you very much Scott

It’s exactly what I’m looking for :wink:

  • It’s fine for me if I have to update the variable when needed (easier than to update my different queries)
  • I captured that it was returned as a string. I’m struggle configuring the variable itself… I have just done some additional tests with also adding time(v: v.myCustomerVariable) to the range but still without success.

Maybe you have a sample of what I should input in the variable itself?

Thank you for your support.


Not sure if it’s the best solution, I was always trying with a variable of type Query, now I tried with a variable of type Map and I succeeded :wink:


Maybe it’s not the best solution but it’s working !

Thanks for you support.


No problem. Happy to help.

One thought – If you’re recording these “events” in InfluxDB (writing them as time series data to a bucket), you can query them out. For example, if you automatically wrote a new point to InfluxDB every time you refueled the storage tank, you could get the time of the last event. Your variable query would be something like:

from(bucket: "example-bucket")
    |> range(start: 0)
    |> filter(fn: (r) => r._measurement == "example-m" and r._field == "refueled")
    |> last()
    |> keep(columns: ["_time"])
    |> rename(columns: {_time: "_value"})

That would return the time of the last refuel “event” stored in InfluxDB and automatically update the variable value.

You’re absolutely right.

I didn’t think about storing these dates in database but that could be an option as well :wink:

For now I’m all set with the map type variable. But definitively I’ll evaluate if it’s not easier to store that info into an influx series.

Thanks again, this helped me a lot !