Creating nested filters
Nested filters are used when the query requires a more complex set of conditions.
Nested filters mean there is a priority set to a group of conditions while the other group or groups are set with a different priority.
The most basic rule is that the AND operation is prioritized before the OR operation.
Nesting filters allow us to ask more complex questions but implement them easily with the drag-and-drop method.
Getting ready
We are required to set these conditions in the query: retrieve the sales revenue for USA for the car maker Leep (there is an AND relation between the first two conditions) OR retrieve Model Colours that equal BLACK.
How to do it...
We will create the three conditions by dragging-and-dropping the relevant objects from the universe structure to the Query Filters pane:
- In order to create a nested filter between the first and the second filter, we will drag-and-drop the Country filter on the Maker filter, as shown in the following screenshot:
- The result will be a nested filter that is bound with a bracket, as shown here:
- We click on the external And operation and turn it into the Or operation, as shown here:
- We will get the following results on clicking on the Run query button:
Examining the results will show data for the car maker Leep in USA (the AND condition) as well as the countries and makers' sales revenue with black color models (the OR condition).
How it works...
Nested filters use brackets in order to prioritize filter groups. By using the simple drag-and-drop technique, we can establish a relatively complex statement of filters. This makes it a very flexible method of querying.
There's more...
Filters can be further nested into more complex subsets. There is no limit to the number of possible conditions that can be put in one query; however, we need to remember that the more conditions we create, theoretically, we are decreasing the number of rows that will be returned. On the other hand, the query is requested to execute more functions in order to retrieve the data.