Using and set up Multi-value variable from Table request

Hello, I’m using Grafana 13.2.0 and a postgreSQL datasource.

Since I faced a issue with my post here and as it appears it is a known issue on Grafana I’m asking a more general question to get some ideas on how to do what I would like to have (or at least get the closer at possible).

Here what I would like to have and see:

When I’ll select a ship, then a system, and then an equipment, I’ll get a list of tag_name on the right panel (If I change system or equipment the list will change). Then, I would like to be able to click on the tag_name or alias so it appears on the timeserie panel on the right. This is easy using links. The tricky part is I would like to do mutliple selection from the right panel to show multiple tag_name on the timeseries. I was not able to find a solution using links to add/remove a value on a multi-value variable. Moreover, I’d like to be able to change the variable system and equipment without loosing the initial selection. For exemple I’d like to be able to select a tag_name in the equipment “propulsion” (like on the screenshot) AND in the equipment “engines” (a different tag_selection will appear)

If you have some idea to start with, or dashboard using similar functionnality your insight will be much appreciated.

Thank you

Nicolas

The cleanest approach is to separate the available tags from the selected tags.

Use chained variables for ship → system → equipment, with the right side table showing the tags available for the current equipment. Grafana documents chained variables for dependent selections.

A multi value variable can handle selecting multiple tags.

However, Grafana’s documented variable and data link features don’t provide a native mechanism for the add/remove/toggle behavior you described while preserving the selection across changing dependent variables.

For the exact behavior, keep the selected tag state separately, for example through a small API/backend or custom panel/plugin. The table can trigger an action to add/remove a tag, while the time-series query uses the complete selected-tag list. Grafana actions support API calls and dashboard variables.

This would allow you to select tags from propulsion, switch to engines, select additional tags, and retain the previous selections.

Thanks for the clear explanation. I indeed already identified all the diffrerent piece of the solution (chain variable, multi-value variable and links) but I was missing the link between them all : the small API/backend or custom panel/plugin.

Unfortunately I do not have the skill and the knowledge to develop such things. I’ll have to keep using native Grafana solution, even that could be not that simple :). I’ll try to think of an alternative that could meet my need.

Thanks again

I found half the functionnality I was looking for with the additional module:

Grafana

It allows to show directly variable into a panel with a check box:

I’ll try to figure out how to store selected variable in another variable/panel with add/remove option so I can use it in timeseries panel

Following up with something you can actually build today, no backend required for the add half .

Grafana data links support a queryparam format specifier: ${selected_tags:queryparam} expands to the current selection of a variable as repeated var-selected_tags=... params.

So a data link on your tag_name table row like:

d/your-dashboard-uid?${selected_tags:queryparam}&var-selected_tags=${__data.fields.tag_name}

Renavigates with the row’s tag appended to selected_tags a separate, flat multi-value variable that’s not part of your ship→system→equipment chain.

Point your timeseries query at $selected_tags instead of $tag_name, and picks from propulsion and engines will coexist in the same list since switching equipment never touches selected_tags.

For that last mile, drop a Business Variable panel (Minimize or Button mode) bound directly to selected_tags next to your timeseries it gives a normal multi-select UI to deselect individual tags.

Thanks @infofcc3

I’m not sure to understand the different step to get this done.

How should I declare the new variable selected_tags ? I’m not sure what queryparam refer to.

PS: I was asking Claude to support me getting an API and a backend running, this is definitely out of my league.

Create the selected_tags variable

Dashboard settings (gear icon) → Variables → + Add variable
Name: selected_tags, Type: Custom
Values: leave empty (if it won’t save empty, use a placeholder like none)
Multi-value: ON, Include All: OFF
Save the variable, then save the dashboard

Test whether it accepts values outside its list

Load your dashboard, copy its URL
Append &var-selected_tags=foo&var-selected_tags=bar to the end and load that URL
Open Variables settings → click selected_tags → check what it shows as selected
Does it show both foo and bar?

Test whether Business Variable panel can display those values

Add/edit a Business Variable panel, bind it to selected_tags
Reload the same test URL from Step 2

Does the panel show foo and bar as checkable rows?

Only if both tests passed add the data link

Edit your tag_name table panel → Data links and action → + Add link
2. URL →

d/<your-dashboard-uid>/<your-dashboard-slug>?${__all_variables}&${selected_tags:queryparam}&var-selected_tags=${__data.fields["tag_name"]}&${__url_time_range}

(swap in your actual dashboard UID/slug from your browser’s address bar)

Toggle One click ON if you want single click instead of a menu
Save

Point the timeseries at the new variable
Edit the timeseries panel → change its query from $tag_name to $selected_tags → save

Thank you very much !

I made it works thanks to your inputs.

Thanks to Business Variable Panel I was able to make it more userfriendly for the selection. I have a panel for the selection and another one for the selected.

Another work around using Business Variable is to use the TreeView functunnality:

All the tags are listed but in a treeview panel, you can filter, show only the selected tags,… Very useful functionnality.

Now I’ll work on the favorite functionnality to save preset of tag selection. I’ll try to use a variable for selected_tags_list_name and store the favorite in a table where Grafana can read&write.

Thanks again for your help.