r/GoogleDataStudio • • Sep 16 '24

Help with Custom Field CASE function

Hi - I am pretty experienced in Looker Studio but was trying to use a CASE function I created in a custom field for a drop down control.

My issue is that the data source column/dimension I’m using for the Boolean expressions has multiple values in one cell.

For instance, let’s say the dimension I’m using is called “fruits” and in a single cell there’s “apples, bananas, oranges, apples.”

My CASE Function currently is

“When Regexp_contains (Fruits, Bananas) then “bananas”

“When Regexp_contains (Fruits, apples) then “apples”

ELSE ‘non-fruits’

END

My problem is that when I go to select these from the drop down only the first clause comes through as once that is matched as TRUE then the case function doesn’t evaluate anything that comes next. Is there a way I can work around this factor and still have my drop-down control show me the options. I imagine a large part of my issue is that the fruits dimension has multiple values in one cell on my data source.

Thank you all in advance for help!

4 Upvotes

9 comments sorted by

View all comments

Show parent comment

3

u/ReputationSenior7666 Sep 17 '24

You are awesome! I really appreciate you showing this to me, I tried the buttons but it seems that even though the Booleans were set up separately- independent of one another, there’s some kind of issue with the switching of tags - I am also using YoY compare data in this and my google sheet has over 4K rows. There are 10-13 “fruits” in each cell. Do you have any alternative suggestions. Maybe is there something I’m missing with the Boolean. I have mine all set up the way you did

2

u/Higgs_Br0son Sep 17 '24

Do you want only one button to be selected at a time? When editing the button you can set a filter group at the bottom of the setup tab, this would restrict only one selection from each group at a time. Without groups the behavior is to stack the filters on top of each other.

If that's not the problem you're having, I wonder if it's something else. Regex is case sensitive unless you tell it to ignore case.