Split Column into multiple columns

  • What Grafana version and what operating system are you using? 10.0.1

  • What are you trying to achieve?

I am new to Grafana and I am using a POSTGRES DB as the data source. Within the POSTGRES DB, there is a table with a column named “distName” that I would like to split into multiple columns using the delimiter “/”.

Below is an example of the “distName” column:


I want to split the “distName” column into five columns: distName1, distName2, Node, Cell, and ID.

  • How are you trying to achieve it?

I looked at the Transformation, but not able to figure out a way to split the columns.

  • What happened?

  • What did you expect to happen?

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?

Will this data always be the same number of 5 columns?

SELECT split_part(distName, '/', 1) AS col1
     , split_part(distName, '/', 2) AS col2
     , split_part(distName, '/', 3) AS col3
     , split_part(distName, '/', 4) AS col4
FROM   tbl;

Thank you for your help.

I changed your input to below to get the query I want

REVERSE(SPLIT_PART(REVERSE(“distName”), ‘/’, 1)) AS id,
REVERSE(SPLIT_PART(REVERSE(“distName”), ‘/’, 2)) AS Cell,
REVERSE(SPLIT_PART(REVERSE(“distName”), ‘/’, 3)) AS eNodeB,
REVERSE(SPLIT_PART(REVERSE(“distName”), ‘/’, 4)) AS Node

Thank you!

1 Like