Hello. I am using Grafana Enterprise Open v10.4.2 with MySQL data connector. I have defined multiple template variables which get used in the following time series visualization:
select
date,
sum($category)
FROM
grover.accountInfo
INNER JOIN
accountData ON accountInfo.switch_key = accountData.switch_key
WHERE
$__timeFilter(date) AND
config_count > 0 AND
account_name IN ($account) AND
geography IN ($geo) AND
region IN ($region) AND
sub_vertical IN ($vertical) AND
sector IN ($sector) AND
accountData.switch_key IN ($switch)
GROUP BY
date
ORDER BY
date ASC
The results are nice - everything works. The template variable called $category is defined not using Multi-value and All. However, I now want to enable Multi-value, which causes a problem. The
sum($category)
without multi-select works fine because it gets translated as
sum(field)
But when Multi-value gets enabled the statement is now:
sum('field1','field2','field3')
which fails because it is not a correct SQL statement. The correct SQL syntax is:
sum(field1+field2+field3)
Can anyone suggest how I could correctly aggregate a multi-select template variable?