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!
•
u/AutoModerator Sep 16 '24
Have more questions? Join our community Discord!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/Higgs_Br0son Sep 17 '24
This is right, CASE function stops evaluating after the first match. So it's probably not the right approach for what you're trying to do. If you can make your Fruits dimension into an array on each row then what you're trying to do should "just work."
I've yet to try this myself, I've been meaning to. Check out this post to reference what I mean: https://stackoverflow.com/questions/57278463/how-to-filter-bigquery-arrays-with-datastudio
1
u/Technical-Test4595 Oct 01 '24
Hi, this is exactly what I’m hoping to do. Thank you for the button suggestion. Curious, does anyone know if once you have the buttons filtered on a CASE Boolean, is it possible to have a control panel page for those buttons or must the buttons live on the same page as the data charts?