When to use AND vs. OR logic?
Introduction
Creating effective filters in HockeyStack requires a solid understanding of AND/OR logic. While these concepts might seem complex at first, this guide will help you master them through clear examples and practical scenarios.
Basic Concepts
AND Logic
When using AND logic, all conditions in the statement must be true for a filter to match.
Example:
A user will only match this filter if they meet both conditions:
They are from Canada
They have made a purchase
OR Logic
When using OR logic, at least one condition must be true for a filter to match.
Example:
A user will match this filter if they meet either condition:
They are from Canada
They have made a purchase
Real-World Example: North America Filter
Let's follow a practical example with a user named Michael Scott who is from the US
Scenario 1: Filter for North American Users
To create a filter for North American users, we would use:
For Michael:
❌ User is from Canada = FALSE
✅ User is from US = TRUE
Result: CORRECT: Filter matches (TRUE) because one condition is met
Scenario 2: Filter for Non-North American Users (Common Mistake)
For Michael:
✅ User is NOT from Canada = TRUE
❌ User is NOT from US = FALSE
Result: INCORRECT: Filter incorrectly matches (TRUE) because one condition is met
For Michael:
✅ User is NOT from Canada = TRUE
❌ User is NOT from US = FALSE
Result: CORRECT:Filter correctly doesn't match (FALSE) because both conditions aren't met
Advanced Usage: LinkedIn Ads Visits Filter
When creating complex filters, such as for LinkedIn Ads visits, you have two approaches for structuring your filters:
Option 1: Bottom-Level AND
Option 2: Top-Level AND (Recommended)
The second approach is more scalable because:
It reduces redundancy
Makes it easier to add new conditions
Maintains cleaner filter logic
💡 Pro Tip
When building complex filters, start with your OR conditions grouped together, then use the "Switch And/Or" feature to add common conditions at the top level. This approach makes your filters more maintainable and easier to update.
Best Practices
Always test your filters with known data to verify they're working as expected
Group related OR conditions together
Use top-level AND for conditions that apply to all criteria
Double-check your logic when using NOT operators
Consider scalability when structuring complex filters
Last updated