Using a dashboard variable in a query

I’m trying to use a simple influx variable in my query which allows for user input to my dashboard.

Consider a simple mapped variable called “threshold”:

high,"3.0"
low,"2.0"
mid,"2.5"

Now, the question is how do I use this map in my query? I’ve tried:

v.threshold

have considered using “dict” and dict.get but not sure where I get key? My goal is for user to select high, medium, or low and for v.threshold to pass the corresponding float value to my query.

Am now thinking the right approach is to use float(v: v.threshold) to pass my float value.

Hello @leeprevost,
Thank you for sharing your solution!!

Hi there :wave:
I’m having trouble using the custom dashboard variables and I don’t get either if I’m using them improperly, or simply I don’t know how to access them.

I’m doing some math calculations and I would gather my constants under a single variable, so:

I created a custom “map” variable named _myVar with 7 key,value pairs, then when accessing by dot notation: v._myVar.key1 I get:

error: expected {A with C: B} (record) but found string

As long as I use always the same default value, I understand that I can simply cast to float v._myVar, but what if I want to use multiple variables at the same time?