Search code examples
looker-studiocalculated-field

Datastudio split and convert a string


I do have a Dimension which contains ex: campaign-20022020 the numbers are the date on which the campaign started. I've sliced the string into 20022020 with SUBSTR(Campaign, -8, 8)

How do I manage to convert the Date 20022020 which is DDMMYYY to DD-MM-YYYY In Datastudio the default settings are YYYYMMDD

I've tried TODATE(Campaign Split, "%d-%m-%Y", "%d%m%Y") (Campaign Split is the field from Campaign which I've split) but that gives me a null Error


Solution

  • A single calculated field does the trick:

    TODATE(SUBSTR(Campaign, -8, 8), "%d%m%Y", "%Y%m%d")
    

    Google Data Studio Report to demonstrate.

    2]