Skip to main content
Solved

"Equals" vs "Contains" on where clauses for arrays


We have an event that has a property that can be one of 4 values, for simplicity, let’s say it can be A, B, C, or D. When looking at the event I want to only see events that have the property value of A or B. I’ve been switching between “equal” and “contains” on the where clause assuming they would have the same result (all of the property values are completely unique, so there should be no overlap with contains), but the contains is returning more results than the equals. 

 

I can’t find anything in the help docs to explain the expected behavior of both. Appreciate any ideas anyone has here. Thanks!

Best answer by Saish Redkar

Hey @Connor ,

If you want to chart out only the events with property value of A or B, then you should be selecting both the values of A and B ( essentially acting as OR ) in the where clause. Both “=” and “contain” should work as long as the event properties are captured as single values. I tried replicating your use case in this demo chart and both ways should ideally give you same results.

Since you mentioned “arrays” in the question title, are those event properties captured in an array or as single values?

 

 

View original
Did this topic help you find an answer to your question?

2 replies

Saish Redkar
Expert
Forum|alt.badge.img+10
  • Expert
  • 1378 replies
  • Answer
  • July 15, 2021

Hey @Connor ,

If you want to chart out only the events with property value of A or B, then you should be selecting both the values of A and B ( essentially acting as OR ) in the where clause. Both “=” and “contain” should work as long as the event properties are captured as single values. I tried replicating your use case in this demo chart and both ways should ideally give you same results.

Since you mentioned “arrays” in the question title, are those event properties captured in an array or as single values?

 

 


sydney.koh
Team Member
Forum|alt.badge.img+8
  • Amplitude Support
  • 127 replies
  • July 15, 2021

Hi Connor,

 

I agree with Saish could you also comment on if your values are in arrays as well. That would make the equal and contains return different values since arrays have more than one value.

 

Best,

Sydney


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings