Using Variables in Field Overrides

Hi,

I’m using Grafana Cloud.

I want non-technical users to be able to hide columns in my table panel. Is it possible to do this using variables?

I have a variable which lists the column names, and I’d like to target that variable with a Hide in Table override.

However, Field Overrides don’t seem to be able to access variables. I’ve tried accessing via field name ${hide_cols}, as well as via regex ${hide_cols:regex}.

If there is a way to do this, with or without variables, please let me know.

Thanks.

Use variable with the right syntax for used datasource, but in the query. So you are not hiding, but selecting columns for that table in the panel query.

2 Likes

here is one way to do it:

define a variable:

then craft your sql statement to use the variable:
image

then depending on the variable selected:
all:

detail:

more detail:

both selected:

1 Like

beat me to it :slight_smile:

2 Likes

Thanks both.

There’s also another workaround which I found: you can use a Filter fields by name Data Transformation in the panel itself, which can reference the variable.

I’ve marked the post with detailed images as the solution.

1 Like