# Dynamic filtering

When using the feature to [show Power BI reports in your system](/technical-documentation/api/show-report-on-your-system.md), it is often necessary to automatically apply a filter to the data when opening the report.

This feature is called dynamic filtering and is available in Power Embedded.

### 1. How to configure dynamic filtering

To configure dynamic filtering, go to the [Datasets](https://admin.powerembedded.com.br/Datasets) page.

Search for the dataset you want to configure dynamic filtering for, click the **Actions** button, and select the **Dynamic filtering (API)** option.

<figure><img src="/files/BcAGob51FsGgxGZ1pCip" alt=""><figcaption></figcaption></figure>

This is the dynamic filtering configuration screen:

<figure><img src="/files/93cC7bRPyoKU9gEzMbxP" alt=""><figcaption></figcaption></figure>

On the dynamic filtering screen, you will need to configure 3 parameters:

* **Property name in the API call**: This is the name of the property that will be used to pass the value to be filtered in the API call. This property name can be defined by you, and must be used in the API call.\\

  <figure><img src="/files/TeKfEdiixVVTy1aGaebZ" alt=""><figcaption></figcaption></figure>
* **Parameter name in the model**: This is the name of the table and column that will be filtered in your report. The format of this field must follow the table/column pattern and is case sensitive, meaning there is a difference between uppercase and lowercase, and it must match exactly what is in Power BI.\\

  <figure><img src="/files/E0ilWFWQPuGJKg2jr8bu" alt=""><figcaption></figcaption></figure>
* **Operator**: Which comparison operator should be used to filter the data. In the vast majority of cases, the operator will be "=".

### 2. How to use dynamic filtering

To use dynamic filtering, you will use the **customFilters** parameter in the JSON of the API call.

Example JSON request with CustomFilters and 2 parameters:

```json
{
  "userEmail": "dirceu.resende@powertuning.com.br",
  "organizationId": "4b532635-a0c6-48ae-bea8-a5197c63f057",
  "reportId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "customFilters": [
    {
      "key": "_loja", // Store parameter that will filter dLojas/FD_LOJA
      "value": "5" // The store code that will be filtered
    },
    {
      "key": "_funcionario", // Employee parameter that will filter
      "value": "12" // The employee code that will be filtered
    }
  ]
}
```

API call response:

<figure><img src="/files/aUDt93igcnIO4BhKMuhn" alt=""><figcaption></figcaption></figure>

When embedding this URL in your system, the user will be directed to this URL:

*<https://demo.powerembedded.com.br/Organization/4b532635-a0c6-48ae-bea8-a5197c63f057/Report/a91ff398-849d-40bd-b40a-e40229f273eb><mark style="color:red;">**?filter=dLojas/FD\_LOJA eq 5 and dFuncionarios/FD\_FUNCIONARIO eq 12**</mark>*

When opening the report, we can observe that the data has been filtered correctly:

<figure><img src="/files/MCmHmjvlReEJlkBidwAU" alt=""><figcaption></figcaption></figure>

### 3. Notes on dynamic filtering

* The columns to be filtered must be listed in the report's Filters panel.
* The table and column name is case sensitive, meaning there is a difference between uppercase and lowercase. The name must exactly match what is in the model.
* **Table** and **Field** names are case sensitive, but **values** are not.
* Hidden fields in the report view can still be filtered.
* Avoid using accents and spaces in the column or table name.
* For more information, refer to [this Microsoft documentation](https://learn.microsoft.com/en-us/power-bi/collaborate-share/service-url-filters).


---

# 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://docs.powerembedded.com/administration-portal/artifacts/datasets/dynamic-filtering.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.
