In one graph panel, I would like to repeat a query (query A, query B, etc) based on a multi value variable. I know I can repeat the panel based on the variable, but I’d rather have query repeat in the same panel so all the values are plotted in the same graph panel.
The basic syntax for my query is: SELECT column_name FROM $variable_name
You’re exactly right that with ‘repeat’ turned on in a panel, you’ll get one panel for each unique value.
Your example is pretty abstract, tough to get your direction, but the following URLs:
…show how to use wild cards (aka regex) to kinda behave like multiple queries. If that’s not helpful, perhaps provide a little more detail on what you’re after.
Hi @nkoetje
I am also trying to repeat queries for multiple values in the same panel instead of panel repetition.
Did you find any solution for the issue ?
Small addition: if you have multiple series (as in my case) you might want to make it respond to the variable selector.
For example, I’ve got three different metrics:
temp
pressure
humidity
And three different rooms:
cellar
bedroom
spare bedroom
If only e.g. bedroom is selected, the query above will still show data for all rooms. To get around this I added a WHERE statement after FROM:
WHERE INITCAP(pico_id) IN (${room})
… the INITCAP is just there because my variables are capitalised but the pico_id field in the database isn’t.
So the full query is:
SELECT
time AS "time",
MAX(${metric:raw}) AS "${metric:raw}",
pico_id
FROM ambient_data
WHERE INITCAP(pico_id) IN (${room})
GROUP BY
pico_id, time
ORDER BY 1