Can you use LIKE in a custom dimension?

I have a custom dimension that returns a “yes” or “no” based on an OR condition that operates on two different dimensions. 

I’ve provided the code for this custom dimension below:

if(${question.main_topic}"Somatic Dysfunction Of The Sacrum." OR ${question.modifier}="Neutral, Sidebent Right, Rotated Left", yes, no)

As you can see in the code, the two fields are checked for a specific value using the “=” operator.

My question is whether I can replace the “=” operator with another operator that is more similar to “LIKE” in SQL or “contains” in Looker.

For example, instead of searching ${question.main_topic} for a value of “Somatic Dysfunction Of the Sacrum”, specifically, what if I wanted to search it for any value that is LIKE or CONTAINS a value of “Somatic”.

Is that possible?

Solved Solved
0 2 1,369
1 ACCEPTED SOLUTION

Using Snowflake I was able to do something similar in my instance:

type: yesno

sql:

contains(upper(${question.main_topic}),'SOMATIC')

or 

${question.modifier} = 'Neutral, Sidebent Right, Rotated Left'

;;

View solution in original post

2 REPLIES 2

Using Snowflake I was able to do something similar in my instance:

type: yesno

sql:

contains(upper(${question.main_topic}),'SOMATIC')

or 

${question.modifier} = 'Neutral, Sidebent Right, Rotated Left'

;;

Thanks @n_davis

I took your code example and create a custom dimension that looks like this:

if(
contains(${question.main_topic}, "Somatic")
OR
contains(${question.modifier}, "Neutral, Sidebent Right, Rotated Left"),
yes,
no
)

I used a custom dimension instead of writing to a view so allow a user to more easily customize the values to search for in the dimensions.

Top Labels in this Space
Top Solution Authors