Applying a report filter in the query

Created by André Carvalho, Modified on Thu, 22 Dec 2022 at 04:06 PM by Virtual Agent

The current report filtering method is versatile, although, depending on the query complexity, may not be the most efficient. DEV Express currently loads all the info regarding a view or query, and only applies the filter once the loading is done, according to the report's configuration.

This makes it easier to interact with the different aspects and information from a given report. However, it is good practice to apply a filter directly in the SQL query, in cases where a high number of rows can potentially be returned.


How-to:

Create a side table

First we will add a new query in the available data source. This query should consist of a list of things we want to filter, based on the report's current view. We're looking for workflow codes in this example:



Create report parameters

Next we'll be adding a parameter. This parameter should contain values added in the previous query.

The parameter's name should be used from now on. Make use of the configuration shown in the picture below and adjust the values if required:



Add parameters to the query

At this moment we will edit the query and add a condition. We usually compare the parameter with the workflow's code or its ID. In this particular case we'll be using the code: where [WKF Code] in (@AGIRCODE)


The parameter was named as AGIRCODE in the example below. Once you're done with the condition, click Next.



It's time to configure the parameter. Click on Add, then click on the new parameter and select the type Expression. Next, set the variable type that the report should filter. In case you're not sure, select string.


In the Value space, click on the 3 dots, select the fields option on your left, select parameters and add the parameter you've created in the previous step (AGIRCODE in this example). Then click OK. It should look like this during this step:



Add filters

Finally, we'll add filter using the parameters we've just created: in this case, filtering through either code or ID within the report itself. To do so we'll use the filter editor: select the workflow's code or ID (as we've done previously) and configure it using the interface to create a statement. In this case we are stating that the code/ID should be equal to the parameter's value:



Et voilá


The report should remain unchanged in regards to configurations and usage. Currently, the use of multivalues is not possible. Check this tutorial page in the future for further developments.


Some useful articles may be found here.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article