英文:
hide or show columns in grafana with a variable
问题
I am creating this table, however, I am trying to hide/show columns based on a variable (the user can select which columns they see).
我正在创建这个表格,但是我试图根据一个变量来隐藏/显示列(用户可以选择看到哪些列)。
I came up with the following code:
我想出了以下的代码:
select
Rank() over (Partition BY score
ORDER BY Speler) ranking,
Speler, $column, Rank as '# pred', Naam as 'Team pred', position as '#', score from fact_score_sheet_act
where Speler in ($Names)
ORDER BY Speler, Competitie, RANK ASC
$column is a variable containing the column names.
It only shows the name as a value, instead of values from the database.
$column是一个包含列名的变量。
它只显示名称作为值,而不是来自数据库的值。
What am I doing wrong?
我做错了什么?
英文:
so i am creating this table, however i am trying to hide / show columns based on a variable (user can select which columns she/he sees).
I came with the following code:
select
Rank() over (Partition BY score
ORDER BY Speler) ranking,
Speler, $column, Rank as '# pred', Naam as 'Team pred', position as '#', score from fact_score_sheet_act
where Speler in ($Names)
ORDER BY Speler, Competitie, RANK ASC
$column is a variable containing the column names
it only shows the name as value, instead of values from the database,
What am i doing wrong?
答案1
得分: 2
你的变量被替换为带引号的逗号分隔列表。因此,MySQL 将其解释为字符串列表,并将它们作为这样返回。
关于这个问题的文档说:
>对于 MySql 数据源,默认行为是将多个值作为带引号的逗号分隔字符串连接起来:'server01','server02'。在某些情况下,您可能希望获得一个不带引号的逗号分隔字符串:server01,server02。您可以使用下面列出的高级变量格式选项来实现这一点。
在您的查询中使用${column:csv}
。
英文:
Your variable is substituted with quoted comma-separated list. As a result MySql interprets it as a list of strings, and returns them as such.
Documentation on this matter says:
>[T]he default for the MySql data source is to join multiple values as comma-separated with quotes: 'server01','server02'. In some cases, you might want to have a comma-separated string without quotes: server01,server02. You can make that happen with advanced variable formatting options listed below.
Use ${column:csv}
in your query instead.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论