Clickable table variables

Hello,

I’ve been using Grafana (v8.4.x) for about a day, experimenting with low-frequency (that is, quarterly, monthly, daily) data. To get going, I’ve started with a minimal three-column table called grafana in Postgres, done the way you might have done a primitive time series table with IBM DB2 in the 1980s. The table itself looks like this:

create table grafana(
    series text not null, 
    date date not null, 
    value double precision)
                   Table "public.grafana"
 Column |       Type       | Collation | Nullable | Default
--------+------------------+-----------+----------+---------
 series | text             |           | not null |
 date   | date             |           | not null |
 value  | double precision |           |          |

What I think I want to do is to first have a table view which displays the results of the following query:

select distinct(series) from grafana order by series;

As this is an experiment, just about anything can be added here, starting and ending dates, frequency, number of values, etc.

Here I think want to click one of the series in the table and save it in a variable.

Next, once selected, I need to draw a graph of the series name selected earlier.

That query would be something like:

select date, value from grafana where series = 'xxxxxx';

Naturally, graphing arbitrary series works well, Grafana sorts the dates for you, no surprises here. Haven’t tried nulls.

What do I need to know to be able to store the result of the first query table selection in a variable and use it in the where clause of the second query? Does the table work for this sort of thing?

Thanks very much.

Welcome,

You can assign data to variables. Check this out if it serves your purposes

Thanks for this. While the itself video didn’t show me what I immediately needed, it certainly pointed me in the correct direction in continuing this treasure hunt. What was immediately useful was

In prinicple, this solves the problem of the “second” dashboard, how to set a variable, and how to get it to be used by the query. Several steps in the right direction.

1 Like