How to execute different queries depending on Custom value

Steps to execute different queries

Step 1: Create table in PostgresSQL through this query.

Step 2: Now create new Grafana dashboard and select database in my case(Postgres) selected and then select Stat visualizations.

Step3: Create variable and select variable type custom and give custom options in my case(ie.10,20).

Step 4: In code area execute the query shown in screenshot for execution different queries depending on custom variable value.

Final Output for value 10 selected.

Final Output for value 20 selected.

Great job with these examples but this approach of embedding queries in a table along with static values is bad design.

And then you are not using the embedded queries anyways

Thank you for your feedback! I’ll refine the approach to avoid embedding unused queries and focus on a cleaner design. Your input is appreciated!