Skip to main content
Solved

Dynamic Table - filtering by 2 properties, event and profile


Forum|alt.badge.img+1

Hello!

I am setting up some dynamic tables inside a flow and am wondering if I can get fancier with the filtering - I read the guides / posts about excluding certain products so I feel I have a good grasp on the beginning of what I want. But I am trying to exclude/include certain products based off of multiple conditions and running into some roadblocks!

Background info: Our users sign up to try promotional items at specific retailers - and they can select which one is their preferred store. This gets passed into the metric ‘AcceptedinCampaign’. An email is then triggered reminding the user to go into that specific store.

The addition I’m looking to add: There are many items on promotion that the user may not have signed up for yet; and some of these may also be at the same retailer. These are currently passed to a custom profile property called ‘products’. What we want to add to the email mentioned above is a second section - if the user has other promotional products at the same retailer they selected, then promote those products so the user is (hopefully) incentivized to pick up more than one thing.

Right now I’ve been able to add these product recommendations using a Dynamic table no problem, but where I run into issue is trying to match and/or filter by specific retailers. An example of what the product recommendations table looks like:

And if I were to filter by Walmart only, no problem:

Added via code inside the dynamic table, {% if products.retailers = 'Walmart' %}

 

 

But when I try to ‘match’ the event preferred retailer {{ event.payload.preferred_location.name }} with the dynamic table products.retailers is where I run into issue. What I originally tried was setting up a few sections that each looked the same, but had a different filter. So the first dynamic block would be Walmart, the next Whole Foods, etc just to keep it “simple”. I tried a few different iterations of the show/hide logic but could not get it to work.

For example in the show/hide logic I tried:

  • Walmart in event.payload.preferred_location.name and Walmart in products.retailers
  • event.payload.preferred_location.name = ‘Walmart’ and products.retailers = ‘Walmart’

and other iterations switching around use of ‘in’, ‘and’, etc.

If there’s some other method to do this, or any other ideas, I would love to do this! Thank you.

Tiffany

Best answer by Byrne C

Got it! It’ll be hard to get the syntax exactly right without seeing the event data associated with the retailer, but I can offer a couple suggestions.

I noticed you’re using Walmart in event.payload.preferred_location.name. There should be quotes around the location, so the syntax should actually be 'Walmart' in event.payload.preferred_location.name. Some people will also run into issues when they use curly quotes (like this ‘’) instead of straight quotes (like this ''). Make sure whatever quotes you’re using are straight quotes, so the logic works correctly.

If event.payload.preferred_location.name isn’t a list data type, you might want to use this instead: event.payload.preferred_location.name == 'Walmart'

Finally, if neither of these suggestions end up working, I’d recommend reaching out to our support team at klaviyo.com/support. They’ll be able to work on your template with you to help find syntax that works.

Let me know if I can answer any additional questions!

-Byrne

View original
Did this topic or the replies in the thread help you find an answer to your question?

3 replies

Byrne C
Community Manager
Forum|alt.badge.img+10
  • Community Manager
  • 72 replies
  • January 21, 2025

Hi ​@tiff_official,

I believe I understand your goal! How are the preferred retailers stored in a profile? Are they saved as profile properties, or do they exist as properties in an event? If they’re event properties, are they properties of the event that triggers the flow, or of a separate event?

Just want to make sure I have a full understanding of the issue, before I suggest!

-Byrne


Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 1 reply
  • January 21, 2025

Hi Byrne!

The preferred retailer is a part of the flow triggered event.

The retailer(s) associate with the product suggestions are saved to the users profile

 


Byrne C
Community Manager
Forum|alt.badge.img+10
  • Community Manager
  • 72 replies
  • Answer
  • January 23, 2025

Got it! It’ll be hard to get the syntax exactly right without seeing the event data associated with the retailer, but I can offer a couple suggestions.

I noticed you’re using Walmart in event.payload.preferred_location.name. There should be quotes around the location, so the syntax should actually be 'Walmart' in event.payload.preferred_location.name. Some people will also run into issues when they use curly quotes (like this ‘’) instead of straight quotes (like this ''). Make sure whatever quotes you’re using are straight quotes, so the logic works correctly.

If event.payload.preferred_location.name isn’t a list data type, you might want to use this instead: event.payload.preferred_location.name == 'Walmart'

Finally, if neither of these suggestions end up working, I’d recommend reaching out to our support team at klaviyo.com/support. They’ll be able to work on your template with you to help find syntax that works.

Let me know if I can answer any additional questions!

-Byrne