Search code examples
regexlooker-studiore2

Trying to create a field in Google Data Studio that only counts if the name of a list begins with US


I am trying to create a field in Google Data Studio that sums the revenue for lists that begin with US. I know I have to use regex, but it continue to tell me there is an unexpected end to the formula.

Here is the code.

    Revenue WHERE REGEXP_MATCH(List, '^US')

Please let me know if you have any questions.

Thanks!


Solution

  • You can use

    WHERE REGEXP_MATCH(List, '^US.*')
                                 ^^
    

    Or even

    WHERE REGEXP_MATCH(List, 'US.*')
    

    See REGEXP_MATCH documentation:

    • REGEXP_MATCH attempts to match the entire string contained in field_expression. For example, if field_expression is "ABC123":
      REGEXP_MATCH(field_expression, 'A') returns false.
      REGEXP_MATCH(field_expression, 'A.*') returns true.