Search code examples
google-cloud-platformlooker-studio

Google Data Studio how to replace a string character by position?


I am new into Google Data Studio and I am trying to cleanse some Google Analytic data.

For example I have a filed called page which shows the page name. For some pages I have duplicates e.g: contact/product/car and contact/product/car/ (ending in this case with /)

I want to create a field that always replace the last charterer of the page name if it ends with '/' with a space

I have tried this function: REPLACE(ENDS_WITH(Page,"/"), '/','')

But is not working instead giving me true or false.

Someone can help me with this?


Solution

  • Please use regular expression for doing this job:

    REGEXP_REPLACE(Page,"/$","")