Cristian
Cristian

Reputation: 35

Split string in two rows in Google Data Studio

From this:

Column A Column B
2021/01/01 AAA, BBB
2021/01/02 CCC, DDD

To this:

Column A Column B
2021/01/01 AAA
2021/01/01 BBB
2021/01/02 CCC
2021/01/02 DDD

Upvotes: 2

Views: 2851

Answers (1)

Diego Queiroz
Diego Queiroz

Reputation: 3411

DataStudio doesn't offer a solution for this kind of data manipulation.

However, this can be easily done with BigQuery or most modern databases.

WITH table AS (
    SELECT '2021/01/01' date, 'AAA, BBB' values
    UNION ALL
    SELECT '2021/01/02' date, 'CCC, DDD' values
)
SELECT
    table.date
    , value
FROM
    table
    CROSS JOIN UNNEST(SPLIT(table.values,', ')) value

Result:

table

Upvotes: 4

Related Questions