---
title: "Creating your own filters "
url: "https://kb.retailsonar.com/en/article/creating-your-own-filters"
language: "en"
last_updated: "2026-06-24T11:05:37.717Z"
---

# Creating your own filters 

### **Introduction**

Please note that this functionality can only be used by **Power users** on the platform! 

The **RetailSonar query builder** offers an easy way to create and adjust advanced filters using an SQL-like syntax. Currently, it's available for editing the **location and zone filter**. Access it by clicking on the ![](https://cdn-assets.productfruits.com/2d7d5107-d8e1-4737-aaed-7b4d9dc3b7cb) icon.

![](https://cdn-assets.productfruits.com/a1ca0afd-c1d4-4382-b9cb-7dfe02a91e2e)

* * *

### **Screen display**

![](https://cdn-assets.productfruits.com/7ea83add-b0f2-4847-84b3-145ee8e213cf)

Filter Management **(1)**:

-   Apply: Add the filter to the *working view*
-   Clear: Reset to default (own brand group for locations, all zones for zone filters).
-   Cancel: Undo changes and revert to the filter before opening the query builder.

Operators **(2)** and Filters **(3)**:

-   Use operators and filters to create subsets of locations or zones and apply conditional filters to those subsets.
-   Combine subsets using set operators: union, except, or intersect.

Syntax Window **(4)**:

-   Textual representation of your filter, editable directly in this window.

* * *

### **How to create a view in the query builder**

#### SELECT statement

Start with a select statement to choose locations or zones.

-   For **locations**: Add brand groups, brands, or locations by name to the filter.
    -   Click on the name of a brand group, brand, or location to add them to the filter.
    -   Combine groups, brands, and locations in the **SELECT** clause.
    -   In this example, locations from brand group "Direct competitors," brand "Carpetright," and a single location "My Company Alkmaar" were added to the filter.

```plaintext
SELECT "Direct competitors", "Carpetright", "My Company Alkmaar"
```

-   For **zones**: select an environment and specify the locations around which to apply these environments.
    -   Click the environment filter.
    -   Use the **AROUND** operator.
    -   Select the specific locations for the environment filter.
    -   In this example, the primary catchment area was applied around all locations of the Company brand.

```plaintext
SELECT primary catchment area AROUND "My Company locations" 
```

#### CONDITIONAL statement

After the select statement, add conditional statements to include or exclude zones/locations based on characteristics.

-   For **locations**:
    -   Use the **WITH** operator to create conditional statements based on location characteristics.
    -   In the example, we refine the selection to locations with consistently insufficient parking and a daily passage of more than 1000 cars, utilizing the **WITH** and **AND** operators in the **SELECT** statement.

```plaintext
SELECT "Direct competitors", "Carpetright", "My Company Alkmaar" 
WITH "Parking" = 'Always insufficient' 
AND "Passage (location)" > 1000
```

-   For **zones**:
    -   Use the **WHERE** operator to create conditional statements based on zone characteristics (KPIs with the "usable in zone query builder" flag).
    -   In the example, we narrowed down zones to those with over 10,000 inhabitants.

```plaintext
SELECT primary catchment area AROUND "My Company" 
WHERE "Inhabitants" > 10000
```

* * *

### **Combine filter queries**

You can **combine multiple filter queries** (select statements with or without conditional statements) by using the **SET operators** UNION, EXCEPT, and INTERSECT.

-   In the example below we combined all direct competitors with all own company location that have good visibility.

```plaintext
SELECT "Direct competitors" 
UNION 
SELECT "My Company" WITH "Visibility" = 'Good' 
```

* * *

### **Extra information on filters and operators**

-   Clicking on a **grey folder icon** next to a zone, location or characteristic name will expand the folder. Clicking on the name of a zone, location or characteristic will directly add it to the filter.

![](https://cdn-assets.productfruits.com/7bb3e6cf-c314-441f-a6fe-b3f1b4362cc1)

-    The RS query builder will **limits the operators and filters you can click on** to those that makes sense from a syntax perspective. For example, you can only click on the WITH operator after you generated a valid SELECT statement.
-   Underneath the syntax window **red error messages** will inform you whenever the syntax is compromised and it will guide you to a correct syntax.
-   Note that
    -   the location characteristics are, in fact, visible (!) attributes. So these are not KPIs.
    -   the zone characteristics, however, are KPIs.
