Search code examples
looker-studio

Literal character as an argument in Google Data Studio SUBSTR() function


I have a quick question. I have a problem with SUBSTR() function in Data Studio. I am trying to make calculated file using function such as SUBSTR(example_file, 6, 2). But the problem is that in my source data (Google Analytics) 6 and 2 is defined as a separate field. Because of that GDS read this not as a number but as another field. I tried CAST function, excape character like "/" or r'x'. I also tried (1500-1494) to gain 6 for example and get the number in quota. But none of this were working. How could I tell GDS to read this 6 or another number as a real number - not a field.

I would be very pleased for the answears.


Solution

  • If there is a field with the name 2, use for the number two a zero in front of it:

    SUBSTR(test,02,1)
    

    Doing any calculations inside the Substr ranges is not allowed. Thus 3-1 does not work.