# How to visualize multiple data points from one table

**URL:** <https://community.grafana.com/t/how-to-visualize-multiple-data-points-from-one-table/117538>\
**Category:** Dashboards\
**Created:** [March 21, 2024, 9:49am UTC](https://community.grafana.com/t/how-to-visualize-multiple-data-points-from-one-table/117538 "2024-03-21T09:49:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bennetle](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@bennetle](https://community.grafana.com/u/bennetle)\
**Post date:** [March 21, 2024, 9:49am UTC](https://community.grafana.com/t/how-to-visualize-multiple-data-points-from-one-table/117538/1 "2024-03-21T09:49:58Z")

</div>

I’m new to Grafana and I want to visualize data from Postgres. The table has fields like timestamp, temperature, and sensor\_id (uuid). Is it possible to create a separate line for each uuid without having to use multiple queries?

---

<div class="post-metadata">

**Author:** ![jangaraj](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jangaraj/32/39197_2.png) [@jangaraj](https://community.grafana.com/u/jangaraj)\
**Post date:** [March 21, 2024, 11:39am UTC](https://community.grafana.com/t/how-to-visualize-multiple-data-points-from-one-table/117538/2 "2024-03-21T11:39:34Z")

</div>

Yes, just `GROUP BY` that `sensor_id` column, which will create dedicated timeseries for each sensor\_id.  
Example (not copy&paste because I don’t have idea about your table structure, so don’t blame if it is doesn’t work, but improve it for your case, pls):

```auto
SELECT
  $__timeGroupAlias(timecolumn),
  sensor_id AS metric,
  AVG(temperature) AS value
FROM table
WHERE
  $__timeFilter(timecolumn)
GROUP BY 1,2
ORDER BY 1
```

---

<div class="post-metadata">

**Author:** ![bennetle](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@bennetle](https://community.grafana.com/u/bennetle)\
**Post date:** [March 21, 2024, 12:10pm UTC](https://community.grafana.com/t/how-to-visualize-multiple-data-points-from-one-table/117538/3 "2024-03-21T12:10:12Z")

</div>

I changed to SQL a bit:

```auto
SELECT "timestamp", sensor_id AS metric, AVG(temprature) AS value 
FROM temprature
GROUP BY 1, 2
ORDER BY 1

```

This still returns one line only.

 ![grafik](https://us1.discourse-cdn.com/grafana/original/3X/2/5/259b76227e3d4fcb00545984e9a01d8352273563.png)  
Is “timeGroupAlias” and “timeFilter” important? I got “interpolation failed: macro \_\_timeGroup needs time column and interval and optional fill value” so I removed it.

---

<div class="post-metadata">

**Author:** ![jangaraj](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jangaraj/32/39197_2.png) [@jangaraj](https://community.grafana.com/u/jangaraj)\
**Post date:** [March 21, 2024, 12:34pm UTC](https://community.grafana.com/t/how-to-visualize-multiple-data-points-from-one-table/117538/4 "2024-03-21T12:34:30Z")

</div>

Debug results:

- use `Table view` [Panel editor overview | Grafana documentation](https://grafana.com/docs/grafana/latest/panels-visualizations/panel-editor-overview/)
- use `Query inspector` [How To Use Grafana's Query Inspector to troubleshoot issues](https://community.grafana.com/t/how-to-use-grafanas-query-inspector-to-troubleshoot-issues/2630)

You are not showing raw data from that query, so only guess it possible to find what can be wrong. And we can spend a days guessing or you can provide reproducible example with exact results/raw data from the query and then it is possible to pin point what’s wrong in the second. Guess: `sensor_id` is numeric - cast it to be text, because Grafana is picky for data types.

Read doc: [PostgreSQL data source | Grafana documentation](https://grafana.com/docs/grafana/latest/datasources/postgres/#macros) - there are macros and each is for different time column type (there is not just “one” time type in PostgreSQL, so of course my example may not work if you, because you may have different time type in your table).

---

<div class="post-metadata">

**Author:** ![bennetle](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@bennetle](https://community.grafana.com/u/bennetle)\
**Post date:** [March 21, 2024, 12:52pm UTC](https://community.grafana.com/t/how-to-visualize-multiple-data-points-from-one-table/117538/5 "2024-03-21T12:52:39Z")

</div>

I’ll send a screenshot of the Table View, The DB and the Query inspector.

 ![grafik](https://us1.discourse-cdn.com/grafana/original/3X/a/9/a9c83172e4e81a3dd7cc31156d1dd66ffdcc184a.png)

```auto
{
  "request": {
    "url": "api/ds/query?ds_type=grafana-postgresql-datasource&requestId=Q144",
    "method": "POST",
    "data": {
      "queries": [
        {
          "refId": "A",
          "datasource": {
            "type": "grafana-postgresql-datasource",
            "uid": "adgba1fxczthcd"
          },
          "rawSql": "SELECT\r\n \"timestamp\" AS \"time\",\r\n temprature AS metric,\r\n sensor_id AS \"series\"\r\nFROM\r\n temprature\r\nORDER BY\r\n \"timestamp\"\r\nLIMIT\r\n 50",
          "format": "table",
          "datasourceId": 1,
          "intervalMs": 60000,
          "maxDataPoints": 2609
        }
      ],
      "from": "1711003868858",
      "to": "1711025468858"
    },
    "hideFromInspector": false
  },
  "response": {
    "results": {
      "A": {
        "status": 200,
        "frames": [
          {
            "schema": {
              "refId": "A",
              "meta": {
                "typeVersion": [
                  0,
                  0
                ],
                "executedQueryString": "SELECT\r\n \"timestamp\" AS \"time\",\r\n temprature AS metric,\r\n sensor_id AS \"series\"\r\nFROM\r\n temprature\r\nORDER BY\r\n \"timestamp\"\r\nLIMIT\r\n 50"
              },
              "fields": [
                {
                  "name": "time",
                  "type": "time",
                  "typeInfo": {
                    "frame": "time.Time",
                    "nullable": true
                  }
                },
                {
                  "name": "metric",
                  "type": "number",
                  "typeInfo": {
                    "frame": "float64",
                    "nullable": true
                  }
                },
                {
                  "name": "series",
                  "type": "string",
                  "typeInfo": {
                    "frame": "string",
                    "nullable": true
                  }
                }
              ]
            },
            "data": {
              "values": [
                [
                  1711016631828,
                  1711016772342,
                  1711016773673,
                  1711016774634,
                  1711016890219,
                  1711017628902,
                  1711017640039,
                  1711017640246,
                  1711017640414,
                  1711017640631,
                  1711017640795,
                  1711017782222,
                  1711017784536,
                  1711017786969,
                  1711017789550,
                  1711017881066,
                  1711017889558,
                  1711018372014,
                  1711018374261,
                  1711018376541,
                  1711018378224,
                  1711018379763,
                  1711019045417,
                  1711019107115,
                  1711021866575,
                  1711021870368
                ],
                [
                  35.5,
                  35.5,
                  35.5,
                  35.5,
                  5.5,
                  20,
                  20,
                  20,
                  20,
                  20,
                  20,
                  15.5,
                  20,
                  23,
                  17,
                  40,
                  40,
                  35,
                  32,
                  30,
                  25,
                  20,
                  50,
                  20,
                  10,
                  15
                ],
                [
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "ea7f5256-a8ae-481f-aaa3-d9ba0cef0b72",
                  "7e1e0513-e45d-4e7b-9be3-e9173994943a",
                  "7e1e0513-e45d-4e7b-9be3-e9173994943a"
                ]
              ],
              "nanos": [
                [
                  734000,
                  573000,
                  389000,
                  658000,
                  951000,
                  385000,
                  532000,
                  77000,
                  849000,
                  795000,
                  167000,
                  65000,
                  194000,
                  395000,
                  612000,
                  549000,
                  303000,
                  827000,
                  840000,
                  7000,
                  317000,
                  618000,
                  238000,
                  253000,
                  766000,
                  490000
                ],
                null,
                null
              ]
            }
          }
        ],
        "refId": "A"
      }
    }
  }
}

```

 ![grafik](https://us1.discourse-cdn.com/grafana/original/3X/8/d/8d7b02f02affa6110dd306861851cd912bbe326d.png)  
The sensor\_id is not numeric and of type uuid. Could this be the problem?

---

<div class="post-metadata">

**Author:** ![bennetle](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@bennetle](https://community.grafana.com/u/bennetle)\
**Post date:** [March 21, 2024, 1:17pm UTC](https://community.grafana.com/t/how-to-visualize-multiple-data-points-from-one-table/117538/7 "2024-03-21T13:17:08Z")

</div>

It worked. Thank you very mouch for the help.

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [April 13, 2024, 4:06pm UTC](https://community.grafana.com/t/how-to-visualize-multiple-data-points-from-one-table/117538/8 "2024-04-13T16:06:27Z")

</div>


