MSSQL Problem with axes

how can i decide what i want to be X axis and Y axis, because on visualizations config, it brings only 3 options, i would like to choose what is to be show in each Axis.

my select on grafana:
select sum(valor) as ‘Receita 06-2018’,
datafatura as time
from fatura f
left join receitadespesa rd on rd.id = f.idreceitadespesa
WHERE datafatura BETWEEN ‘2018-06-01’ AND ‘2018-06-30’ and idreceitadespesa = 2
GROUP BY datafatura

my result:

the select that i would like to make and show it in lines graph, :
select sum(valor), descricao, MONTH(datafatura), YEAR(datafatura)
from fatura f
left join receitadespesa rd on rd.id = f.idreceitadespesa
where idReceitaDespesa = 2
group by descricao, Month(datafatura), Year(datafatura)
order by YEAR(datafatura)

Hi, @rodolfo2!

The order of columns and their labels is determined solely by your data query. Look what your current query returns - sum of valor that’s being grouped by datafatura. Different kind of aggregation should solve your issue.

Best regards,
Lukas

thanks for reply, i fix it by using $__timeGroup(dateColumn,‘5m’, 0)*, but i’m having a problem, if i try to aggregate by Month, using ‘1M’, says that ‘M’ dont exist, than i have to say to aggreagate by ‘30d’, but some month have less or more than 30 days, how can i fix it? the same for year, if i try to aggregate Year by Year, i tryied put ‘1y’ the aggragation done its bigger than 1y, i couldnt tell how much, but problably bigger than 3 years, other problem that i’m having is that the group by uses my local time to define when its gonna group like today is november,14, if i set timegroup(dateColumn, ‘30d’) it will aggregate every 30 days using de day 14 as “key” (it’ll aggregate like this - 2018/12/14 to 2019/01/13, then 2019/01/14 to 2019/02/13) that aggregation make sense if you uses time filter like last 5 years, but if i try to get a custom range like 2018/01/01 to 2018/12/31 i’d like to have aggregation exactly by month 1, month 2…, if possible to point me a direction i’ll appreciate.