Forum Discussion
How to Filter Multiple Values in a String Field (e.g., Product Categories)?
- 3 months ago
Hello Arso,
Thanks for your input—I had a similar thought, but I’ve found a solution that works perfectly.
It turns out Braze handles this in a rather peculiar way, but it works:
When you create a field in a catalog via the API, you can set the type to "ARRAY". This enables the use of the operator "Include Value". Interestingly, this option is only available if the field is created via the Catalog API, and I’m not sure why that’s the case.
I discovered this while reading the documentation on creating selections via API:
Create Catalog Selections APIHere’s my workflow:
- I create the field via the API.
- Then, I upload a CSV file with the data (next step: automation).
The data in the array field looks like this:
["value1", "value2", "value3"]Hopefully, this solution can help someone else as well!
Hello! If you're doing this operation in the segment tool or on the campaign-level, you can use "matches regex" as a filter, and if you type "metal" in the input field, it would give you all users with a Product Categories attribute, where the value string contains "metal".
If you're doing this in liquid, on the message level, you can use "contains" as an operator to filter for "metal".
Apologies, I didn’t explain it clearly earlier. I’d like to create a catalog with all products and then use a selection to filter them by product category.
In the campaign, it should work so that, for example, 3 random products from the catelog with "Metal" category are selected.
Rano
- Arso3 months agoExpert
Ah, this is a product catalog. You need the selection to randomize the products. Got it.
Unfortunately, in this case, you'll have to split the Product Categories string column into one column per category, with a boolean value - true/false, yes/no. Then you can do a filter on "Metal equals TRUE". You can use the same catalog, keep the existing field and add the new columns on top.
I know this is not an ideal solution but it's the only quick and viable one here. You can submit a feature suggestion on the Product Roadmap page in Braze.
There might be a very complicated way to sort through the catalog within the message, using Liquid, but it will be a very heavy task to do this every time your campaign needs to send. Plus, add the randomization liquid on top and you have a very messy code.
Related Content
- 2 years ago
- 2 years ago
- 2 years ago
- 2 years ago