Grouping, Sorting, and Limiting
The following sections describe how to group, sort, and limit a Semantic Query.
Grouping allows you to aggregate big data sets into more meaningful and manageable subsets of data. You can group query results by a variety of categories, including:
- Group by dimensions
- Group by measures
- Group by dates field
- Group by fiscal dates
Grouping enables you to analyze data at different levels of detail. This example demonstrates the use of both row and column grouping.
Sorting allows you to sort query results by a variety of categories. Query results can be sorted by ascending or descending order. The following are rules for query result sorting:
- Dimension columns are sorted alphanumerically. For example:
- Table fields are sorted according to their data type (numeric sorting in this example). For example:
- Date columns are sorted chronologically (timestamps). For example:
- Each dimension can be sorted by a different aggregated measure when grouping by columns. For example, you can use sorting to help your Sales Representative efficiently manage and prioritize their leads and opportunities. A large number of leads within the CRM database can be sorted by priority, such as lead score. This allows the Sales team to focus on high priority leads. Users can define multiple sorting fields. For example, the following shows aggregated sorting combined with additional alias-based sorting:
You can use limiting to constrain the number of result rows returned in the query results. The limit value is set as part of the SQL “limit” clause. You can customize the default limit value. The Semantic Query supports limits in Run Mode - limits are applied after query result grouping.
Query limits affect how data visualizations are rendered.
Example: For a chart grouped by US State, setting a query limit of 30 will limit the number of states returned in the query result to 30 even though the data source might have data for all 50 states.