Search code examples
looker-studio

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

Solution

  • 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