How do I build a beast mode that will see if " UK " is part of a string?

Reply
Highlighted
Yellow Belt

How do I build a beast mode that will see if " UK " is part of a string?

I'm looking to ceate a beast mode that will look at a string 'Campaign name' and see if it contains 'UK' surrounded by spaces.


Accepted Solutions
Black Belt

Re: How do I build a beast mode that will see if " UK " is part of a string?

Try something like this:

 

CASE

  WHEN `Campaign name` LIKE '% UK %' THEN 'TRUE'

  ELSE 'FALSE'

END

 

 

The "%" is a wildcard that says "Any number of characters can go here". So the expression means "If the value in the `Campaign name` columns has any number of characters followed by a space, then UK then another space, and then any number of characters again, return the value 'TRUE'. Otherwise, return the value 'FALSE'.

 

Let me know if that helps!

View solution in original post


All Replies
Black Belt

Re: How do I build a beast mode that will see if " UK " is part of a string?

Try something like this:

 

CASE

  WHEN `Campaign name` LIKE '% UK %' THEN 'TRUE'

  ELSE 'FALSE'

END

 

 

The "%" is a wildcard that says "Any number of characters can go here". So the expression means "If the value in the `Campaign name` columns has any number of characters followed by a space, then UK then another space, and then any number of characters again, return the value 'TRUE'. Otherwise, return the value 'FALSE'.

 

Let me know if that helps!

View solution in original post

Yellow Belt

Re: How do I build a beast mode that will see if " UK " is part of a string?

Yes I wound up writing something similar, in case you want to do it for multiple countries you could have something like:  

(CASE  WHEN (((`campaign_name` LIKE '% UK %') OR (`campaign_name` LIKE '% US %')) OR (`campaign_name` LIKE '% CA %')) THEN 1 ELSE 0 END )

Announcements
Check out these great solution videos! The new iSolveditWithDomoboard is live, share yours and earn higher rankings in Dojo click here!