Trouble selecting a series override for two queries on the same postgres datasource

Hi there!

I have trouble creating an override for one graph when using two queries (a postgres datasource) on the same data set.

So, I have (1.) daily values:
SELECT
date AS “time”,
name AS metric,
value AS “Daily value”
FROM kpis
WHERE
$__timeFilter(date) AND
name = ‘Uptime’
ORDER BY 1,2

And I have (2.) a weekly average of these values:
SELECT
__timeGroupAlias(date,1w), name AS metric, avg(value) AS "Weekly average" FROM kpis WHERE __timeFilter(date) AND
name = ‘Uptime’
GROUP BY 1,2
ORDER BY 1,2

Now, in the legend the aliases “Daily value” and “Weekly average” are both disregarded and the legend shows “Uptime” (the kpis.name selected in the WHERE clause).

So I can not add a series override, and it only shows me the option to select “Uptime” twice.

Is there a better way to do this, so the value aliases for both queries (“Daily values” and “Weekly average”) are showing up in the legend?

Try this for each of query:

SELECT
date AS “time”,
value AS “Daily value”
FROM kpis
WHERE
$__timeFilter(date) AND
name = ‘Uptime’
ORDER BY 1,2

2nd query:

SELECT
__timeGroupAlias(date,1w), 
avg(value) AS "Weekly average" 
FROM kpis 
WHERE __timeFilter(date) AND
name = ‘Uptime’
GROUP BY 1,2
ORDER BY 1,2

Hi @fadjar340, thanks for your reply!
That did the trick!!

1 Like