It almost worked, I was excited for a moment. I created a datasource variable that allows multiple values including all but that is for the whole panel rather than the individual query. So for example if I have
variable datasource: All
datasource "source 1": select date_trunc('month', approved_at) AS month_start, count(id) as "${datasource:text}" from mytable, group by month_start
datasource source 2: select date_trunc('month', approved_at) AS month_start, count(id) as "${datasource:text}" from mytable, group by month_start
In this case count is displayed on the legend as “source 1 + source 2”, “source 1 + source 2”
This means the variable is for the whole panel, not the datasource for the individual query
However I realised I can achieve what I want in a more manual and annoying way in this instance because postgresql lets you name fields with spaces if you put it in double quotes, so I can write
datasource A: select date_trunc('month', approved_at) AS month_start, count(id) as "source 1" from mytable, group by month_start
datasource B: select date_trunc('month', approved_at) AS month_start, count(id) as "source 2" from mytable, group by month_start
A bit annoying but at least it works for my use case.
So the question remains in general, is it possible to get source 1
and source 2
as a field in a mixed datasource scenario, where the variable is set to the datasource of that query. I.e. in query 1, from source 1, ${datasource:text} == “source 1” and in query 2 from source 2, ${datasource:text} == “source 2”
?