cancel
Showing results for 
Search instead for 
Did you mean: 

Combine AND and OR in a filter

soporteparaptx
9 - Travel Pro
9 - Travel Pro

Hi 

We need to perform a filter based on dimension values, according to AND and OR logic like

(field starts with 1 OR field starts with 2) AND field does not contain 4

Is there a way to perform it? We tried by JAQL but It does not work.

Best

 

7 REPLIES 7

HamzaJ
12 - Data Integration
12 - Data Integration

Hey @soporteparaptx 

Have you tried the Filter Relationship feature? I think this answers your question

https://docs.sisense.com/main/SisenseLinux/filter-relationship-engine.htm

Hi @HamzaJ 

I've seen that, but I'm not clear about how to make it available. Do you know how to enable this feature? It's just on dashboard level also, so it impacts all dashboard, not just a widget, do it?

Thanks!

HamzaJ
12 - Data Integration
12 - Data Integration

I think it is enabled by default. You can check this by going to a dashboard and click on the three dots ,next to the plus-icon to add a filter, and selecting Filter Relationship.

If it is not there , you can enable it by going to Admin > System Management > Configuration > Base configuration > Filters and enable filter relationship

Hi @HamzaJ 

Thanks for the info, sure, it was not enabled. But, unfortunately, I think that is not going to solve the issue. We need to perform AND and OR combination inside a filter of a field, not between filters related to different fields.

Thanks

HamzaJ
12 - Data Integration
12 - Data Integration

Then you could try to do advanced configuration on your filter and add something like this:

{
    "or": [{
        "last": {
            "count": 1,
            "offset": 7
        }
    }, {
        "last": {
            "count": 1,
            "offset": 14
        }
    }],
    "and": [{
        "last": {
            "count": 1,
            "offset": 7
        }
    }, {
        "last": {
            "count": 1,
            "offset": 14
        }
    }]
}

HamzaJ_0-1689845469775.png

This is something that is only applicable within 1 filter. In this case its a date, however you can change it to text or numbers depending on your filter

 

Thanks @HamzaJ 

I have tried this way:

{
  "or": [
    {
      "startsWith": "212"
    },
    {
      "startsWith": "213"
    },
    {
      "startsWith": "215"
    },
    {
      "startsWith": "21101"
    },
    {
      "startsWith": "21102"
    },
    {
      "startsWith": "21114"
    }
  ],
  "and": [
    {
      "doesntStartWith": "215081001"
    }
  ]
}

But if I check the SQL is generating, the AND section is not included...

Any idea about that?

Best!

see this example... it's not working

soporteparaptx_0-1689848827467.png