Column values to labels

  • What Grafana version and what operating system are you using?
    8.1.5
  • What are you trying to achieve?
    have a column count of the status field as it’s own column
    eg
    postgres table data example as below
    client=clientA, status=complete, created_at=1234567890
    client=clientB, status=incomplete, created_at=1234567890
    client=clientA, status=incomplete, created_at=1234567890

displayed in table as
client complete incomplete
clientA 1 1
clientB 0 1

  • How are you trying to achieve it?
    closest I got was
select client, status, count(status) as total from (
    select created_at, client, status
    from tbl_clients
    where $__timeFilter("created_at")
    order by "created_at"
) e group by e.client, e.status
  • What happened?
    I have a multiple rows for the same client with the status per row
  • What did you expect to happen?
    need to rotate the status value (complete,incomplete) to be a label with a count so one line for the client with the status values as a column.
  • Can you copy/paste the configuration(s) that you are having problems with?

select client, status, count(status) as total from (
select created_at, client, status
from tbl_clients
where $__timeFilter(“created_at”)
order by “created_at”
) e group by e.client, e.status

I figured it out using a filter on the column.

1 Like

This topic was automatically closed after 365 days. New replies are no longer allowed.