WHERE Clause
The WHERE Clause, located at the bottom of the Data Model Designer, lets you filter the data returned by your model using SQL conditions. By specifying conditions, you can limit result sets to only the rows that meet your criteria. This is often used to improve query performance or narrow the dataset to relevant values.
When to use the where clause
- Filtering datasets for analysis: Include only relevant records.
- Improving query performance: Limit dataset size to speed up processing.
Build a WHERE clause
- In Data Models and Views, right-click a data model and select Data Model Designer.
- In the WHERE Clause pane, click inside the text box.
- Type the SQL expression that defines your filter condition.
- Click the three vertical dots on the right to open the SQL Scripts Builder.
- Use available keywords, tables, operators, or code helpers to complete your logic.
- Click Validate to check if the expression syntax is correct.
- Click Save.
- On the File tab, click Save Data Model.
WHERE clause fields
| Field | Description |
|---|---|
| Script editor | Enter the SQL condition used to filter data in the cube. |
| Code helpers | Insert operators, brackets, or keywords using toolbar buttons above the script editor. |
| Scripts Keywords | Build expressions using grouped keywords:
|
| Tables | Select from tables available in the data source to reference in the script. |
| Others | Add additional elements:
|
| Validate | Check whether the script executes successfully and meets syntax requirements. |
Examples
Example 1 – Filter by date range:
WHERE OrderDate BETWEEN '2023-01-01' AND '2023-12-31'
Example 2 – Filter by company code:
WHERE CompanyCode = 'COMP001'
Example 3 – Filter by multiple regions:
WHERE Region IN ('North America', 'Europe', 'Asia Pacific')