Grouped and stuck data by days

I have rather simple query (Postgresql):

select created_at, category, sum(profit) as profit
from datasource
group by created_at, category;

I want to create a chart which represents profit per category for every day. I tried to use a time series but I couldn’t stack them. Also I tried to use a bar chart (unsuccessfully). So technically I even didn’t find a way to represent categories with profit inside one date.
How could I do it in Grafana?

Welcome to forum @tylinka

try this

select created_at as time, 
       category as metric, 
       sum(profit) as value
  from datasource
 group by created_at, category;

and make sure your data format is time series

Did you set any additional settings? I used this aliases but still have the same :frowning: I tried to override and use stack option, but it doesn’t help.

Did you set tha format?

Yes, it has date time format

Nope not that. See the previous picture I posted

Right below there is a Format option

1 Like

Wow, I’ve never noticed that… Thank you very much!

1 Like

Would be nice if it defaulted to time series when it sees a time column