https://www.growthbook.io/ logo
#announcements
Title
# announcements
c

colossal-alligator-31194

09/05/2023, 12:39 PM
Hey everyone. Does anyone know if we can have OR conditions in
feature targeting group
? I know we can have saved groups for a single attribute but I wanna have a OR condition over two attributes. like
if product === 'X' OR country === 'Y'
. By default it makes a AND out of the two conditions.
rule-conditions-08cff979d8c5b2b4534d1c73bb137cf7.png
Copy code
{
  "$or": [
    {
      "country": {
        "$ne": "Y"
      }
    },
    {
      "country": {
        "$ne": "X"
      }
    },
    {
      "product": {
        "$ne": "Z"
      }
    }
  ]
}
Copy code
{
  "$or": [
    {
      "product": {
        "$ne": "Z"
      }
    },
    {
      "country": {
        "$nin": [
          "Y",
          "X"
        ]
      }
    }
  ]
}
I tried these but seems to not working.
s

swift-helmet-3648

09/05/2023, 5:27 PM
Hi Afsaneh, let me take a look
🙏 1
@colossal-alligator-31194 If you're using advanced mode with the mongodb query syntax, they should be working as expected ('OR')
I wonder if the issue has to do with something else. How are you testing? Can you confirm the user attributes are being set correctly?
c

colossal-alligator-31194

09/06/2023, 7:06 AM
Hey, thanks for writing to me. the issue was with the negations. I fixed it like this:
Copy code
{
  "$nor": [
    {
      "country": {
        "$in": [
          "X",
          "Y"
        ]
      }
    },
    {
      "product": "Z"
    }
  ]
}
15 Views