Dropdown in dashboards

Hi All,

I am a newbie to grafana. I have made dashboards in grafana using MySQL query. For Example:
SELECT TimeOfDay as time,M00B01, M00B00,
from TSU
where TSU_ID=0;

Now I want to give drop-down option on the dashboard that will allow the user to change the graph based on his selection checkbox he choose i.e. if he selects ‘M00B00’ then data points of ‘M00B00’ only should be fetched from the database against Time. If he select ‘M00B01’ then only ‘M00B01’ should be fetched from database. Or if he selected both option from drop-down he should be able to see the graph for both column.

How can i achieve this? I know I can use variables but what settings or configs to set to achieve this. Thank you. Any help is much appreciated.

You have to basically go to the settings icon on top bar of the dashboard,select variables,now u can manually add variables by typing them out,now go to edit option in the panel and in the where section of the query editor u add metric=variable and u can template

1 Like

Think the workaround is to use the following variable reference ${var:raw} to be able to use it in column selection.

SELECT TimeOfDay as time, ${your_variable:raw}
1 Like