# Custom Filter and Sorting Rules with Base64

{% hint style="info" %}
This feature is available in the following plans:\
~~<mark style="background-color:red;">Free</mark>~~ | <mark style="background-color:$success;">Standard</mark> | <mark style="background-color:$success;">Professional</mark> | <mark style="background-color:$success;">Enterprise</mark>\
[View pricing and plan details →](https://www.docexport.com/pricing/)
{% endhint %}

{% hint style="warning" %}
Please note that this method is very advanced and only applies to a limited number of use cases. You will typically need it only when you:

* want to filter and sort **by multiple complex criteria simultaneously**
* need to enforce a **strict, predefined order** of processing steps
* want to apply **multiple sorting rules** at the same time
  {% endhint %}

{% embed url="<https://youtu.be/TdBTKctKgMg?si=SjdIOv2HCWlRW_ml&t=1655>" %}

## Concept of working with Base64 codes&#x20;

Before encoding, every filter begins as a **decoded configuration object**. This object defines all filtering and sorting logic in a structured format and will then be added to the grouping placeholder.

To build this configuration correctly, you will need:

### **1. The column IDs from your monday.com board**

Each rule - whether a filter or a sort condition- must reference the exact `column_id`.\
We recommend listing all your requirements first and then gathering the corresponding column IDs from your board.

<div align="left"><figure><img src="https://1159009676-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMnVzL8c1pE5zXO95iUKm%2Fuploads%2FkW1KSfZQWqjBvy2FJeay%2FColumnIDCopy.gif?alt=media&#x26;token=a1a1449b-186b-419c-addf-4420e8dda1e9" alt=""><figcaption></figcaption></figure></div>

### **2. Sorting rules using `order_by`**

All sorting configurations must be placed inside an `order_by` array.\
The sequence inside this array defines the exact sorting order.\
For example:

```
order_by: [
  { column_id: "country" },
  { column_id: "state" },
  { column_id: "city" }
  ]
```

This means the data will be sorted **first by Country**, **then by State**, **and finally by City**. You can use as many sorting rules as you like, just add them to the row by separating them with a comma.

### **3. Combined Filtering + Sorting rules**

If your configuration includes both filtering and sorting, the object must always begin with a `rules` section:

```
rules: [...],
order_by: [...]
```

* `rules` defines the filtering logic
* `order_by` defines the sorting logic
* Both must be included when using filters and sorting together

#### Retrieving only the filter string for the 'rules' section via the UI

You can retrieve your filter conditions directly from the UI as a **Base64-encoded filter string**.\
This is especially useful if you only need the filtering part (`rules`) but want to manually add additional sorting or grouping logic afterward.

By copying the filter from the UI:

1. You get a ready-made Base64 **filter** string based on your current UI filter selection.
2. You can **decode** this Base64 string to view the underlying filter object.
3. You may then **combine this decoded `rules` object with your additional requirements**—for example, adding `order_by` sorting rules or expanding the logic.
4. Finally, you can **re-encode the entire combined object back into Base64** and use it inside your template’s grouping placeholders.

This approach gives you a quick starting point for the filtering logic, while still allowing full flexibility for custom combinations of filters, sorting rules and grouping structures.

Please take a look at this article for more details on how to generate and copy a filter string in DocExport:  [Advanced Filtering](https://help.docexport.com/template/advanced-filtering)

### **4. Encoding the configuration into Base64**

Once your decoded object is complete, you can convert it into a [Base64 string](https://www.base64encode.org/).\
This encoded string represents the full logic (filters and/or sorting) in a compact format.

### **5. Inserting the Base64 code into your template**

After encoding, the Base64 string must be placed **directly inside your TableStart and TableEnd placeholder**, this is also where you can add your [grouping](https://help.docexport.com/template/advanced-options/group-by):

* `{{TableStart:...}}`
* `{{TableEnd:...}}`

For example:

```
{{TableStart:GroupByStatus(your_base64_code_here)}}
...
{{TableEnd:GroupByStatus(your_base64_code_here)}}
```

Once inserted, the entire dataset is filtered and sorted strictly according to the logic defined in your Base64 configuration.

This method allows you to combine multiple filters, layered sorting rules, and grouping operations—far beyond what the UI can configure on its own.

## Example Base64 codes with

### Sorting (order by one value) + Grouping

{% stepper %}
{% step %}

#### **Requirements:**

* Group by: Status
* Sort by: Country (ID: country)
  {% endstep %}

{% step %}

#### **Decoded Filter:**

```
order_by:[{column_id:"country"}]}
```

{% endstep %}

{% step %}

#### Base64 Code:

```
e29yZGVyX2J5Olt7Y29sdW1uX2lkOiJjb3VudHJ5In1dfQ==
```

{% endstep %}

{% step %}

#### Final Placeholder:

{{TableStart:GroupByStatus(<mark style="background-color:yellow;">e29yZGVyX2J5Olt7Y29sdW1uX2lkOiJjb3VudHJ5In1dfQ==</mark>)}}

and

{{TableEnd:GroupByStatus(<mark style="background-color:yellow;">e29yZGVyX2J5Olt7Y29sdW1uX2lkOiJjb3VudHJ5In1dfQ==</mark>)}}
{% endstep %}
{% endstepper %}

### Sorting (order by two or more values) + Grouping

{% stepper %}
{% step %}

#### **Requirements:**

* Group by: Status
* Sort by: Country (ID: country)
* Sort by: District (ID: dropdown\_mky1dyp6)
  {% endstep %}

{% step %}

#### Decoded Filter:

{% code overflow="wrap" %}

```
{order_by:[{column_id:"country"},{column_id:"dropdown_mky1dyp6"}]}
```

{% endcode %}
{% endstep %}

{% step %}

#### Base64 Code:

{% code overflow="wrap" %}

```
e29yZGVyX2J5Olt7Y29sdW1uX2lkOiJjb3VudHJ5In0se2NvbHVtbl9pZDoiZHJvcGRvd25fbWt5MWR5cDYifV19
```

{% endcode %}
{% endstep %}

{% step %}

#### Final Placeholder:

{{TableStart:GroupByStatus(<mark style="background-color:yellow;">e29yZGVyX2J5Olt7Y29sdW1uX2lkOiJjb3VudHJ5In0se2NvbHVtbl9pZDoiZHJvcGRvd25fbWt5MWR5cDYifV19</mark>)}}

and

{{TableEnd:GroupByStatus(<mark style="background-color:yellow;">e29yZGVyX2J5Olt7Y29sdW1uX2lkOiJjb3VudHJ5In0se2NvbHVtbl9pZDoiZHJvcGRvd25fbWt5MWR5cDYifV19</mark>)}}
{% endstep %}
{% endstepper %}

### Filtering (e.g. Checkbox) + Grouping + Sorting

You can also retrieve the basic filter condition string directly in the UI and then combine it with the rest of your requirements. Please take a look at this article for more details on how to generate a filter string: [Advanced Filtering](https://help.docexport.com/template/advanced-filtering)

{% stepper %}
{% step %}

#### **Requirements:**

* Group by: Status
* Sort by: Country (ID: country)
* Sort by: State (ID: dropdown\_mky1dyp6)
* Filtered by: "Contacted" check box (ID: boolean\_mky14vdq)
  {% endstep %}

{% step %}

#### Decoded Filter:

{% code overflow="wrap" %}

```
{rules:[{column_id:"boolean_mky14vdq",compare_value:[],compare_attribute:"",operator:is_not_empty}],order_by:[{column_id:"country"},{column_id:"dropdown_mky1dyp6"}]}
```

{% endcode %}
{% endstep %}

{% step %}

#### Base64 Code:

{% code overflow="wrap" %}

```
e3J1bGVzOlt7Y29sdW1uX2lkOiJib29sZWFuX21reTE0dmRxIixjb21wYXJlX3ZhbHVlOltdLGNvbXBhcmVfYXR0cmlidXRlOiIiLG9wZXJhdG9yOmlzX25vdF9lbXB0eX1dLG9yZGVyX2J5Olt7Y29sdW1uX2lkOiJjb3VudHJ5In0se2NvbHVtbl9pZDoiZHJvcGRvd25fbWt5MWR5cDYifV19
```

{% endcode %}
{% endstep %}

{% step %}

#### Final Placeholder:

{{TableStart:GroupByStatus(<mark style="background-color:yellow;">e3J1bGVzOlt7Y29sdW1uX2lkOiJib29sZWFuX21reTE0dmRxIixjb21wYXJlX3ZhbHVlOltdLGNvbXBhcmVfYXR0cmlidXRlOiIiLG9wZXJhdG9yOmlzX25vdF9lbXB0eX1dLG9yZGVyX2J5Olt7Y29sdW1uX2lkOiJjb3VudHJ5In0se2NvbHVtbl9pZDoiZHJvcGRvd25fbWt5MWR5cDYifV19</mark>)}}

and

{{TableEnd:GroupByStatus(<mark style="background-color:yellow;">e3J1bGVzOlt7Y29sdW1uX2lkOiJib29sZWFuX21reTE0dmRxIixjb21wYXJlX3ZhbHVlOltdLGNvbXBhcmVfYXR0cmlidXRlOiIiLG9wZXJhdG9yOmlzX25vdF9lbXB0eX1dLG9yZGVyX2J5Olt7Y29sdW1uX2lkOiJjb3VudHJ5In0se2NvbHVtbl9pZDoiZHJvcGRvd25fbWt5MWR5cDYifV19</mark>)}}
{% endstep %}
{% endstepper %}

## Summary

Using Base64-coded filtering, sorting and grouping rules allows you to:

* Apply complex multi-step filter and/or sorting orders
* Combine multiple filters and sortings
* Go beyond all UI-level limitations

If you need help building a specific Base64 filter, feel free to ask: <support@towerapps.com>&#x20;

{% hint style="warning" %}
**Note:** Filtering and sorting by ***Mirror*****&#x20;or&#x20;*****Formula*** columns is currently not available.\
This is due to limitations in the monday.com API, which does not provide the required data for these column types.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.docexport.com/template/advanced-filtering/custom-filter-and-sorting-rules-with-base64.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
