I have a query A that retrieves the updated monthly data from a table and a query B that retrieves the weekly data. Then, I created 2 reducers to bring the last value from each query and use a mathematical expression ((${MB} - ${MA}) / ${MA}) to calculate this variation. However, this expression doesn’t return anything (NO DATA). If I use the same query in both queries, it works. Do you know where the error is, or do you have a suggestion?
SELECT COUNT(*) FROM {self.table_name} WHERE updated_at >= NOW() - INTERVAL ‘1 months’;
Hi! Do you know if the labels from Query A match the labels in Query B? If not, Grafana won’t be able to match them and will return no data.
If you need to do an outer/left/inner join to match the rows from Query A with the rows from Query B then it might be easier to do that in your SQL query instead.
Label A:
stat_name=“updated_row_month_count” which makes this database call:
SELECT COUNT(*) FROM {self.table_name} WHERE updated_at >= NOW() - INTERVAL ‘1 month’;
Label B:
stat_name=“updated_row_week_count” which makes this database call:
SELECT COUNT(*) FROM {self.table_name} WHERE updated_at >= NOW() - INTERVAL ‘1 week’;
Then I use 2 reduces to retrieve the information, so far so good.
But in the mathematical expression that’s causing issues…