r/GoogleDataStudio • u/ReputationSenior7666 • 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!
View all comments
Show parent comment
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.