In order to improve the performance of my dashboard, I would like to find a way to create a Grafana variable by using another Grafana variable that contains a list of elements.
The source variable is room_ids, which is a Query variable using a PostgreSQL data source. This is the query that defines the source variable:
SELECT DISTINCT roomid FROM periodic_measurements WHERE apartmentid = $apartment AND roomid != 0 ORDER BY roomid;
Now let’s say I would like to use the variable room_ids to create a second variable called room1 that provides the same result of the following Query variable which takes the first element of the list:
SELECT DISTINCT roomid FROM periodic_measurements WHERE apartmentid = $apartment AND roomid != 0 ORDER BY roomid LIMIT 1 OFFSET 0;
How shall a define the variable room1? Shall room1 be a Query or a Custom variable? Shall I change room_ids to provide an array rather than a list? I have tried different combinations with no result.
Any help is appreciated.
I am running Grafana version 9.5.1. on Linux Ubuntu 22.04.2.
Bernardo Di Chiara