query_metrics
Query the dbt Semantic Layer to analyze business data by grouping, ordering, and filtering metrics, dimensions, and entities for precise insights.
Instructions
This tool allows ordering and grouping by dimensions and entities. To use this tool, you must first know about specific metrics, dimensions and entities to provide. You can call the list_metrics, get_dimensions, and get_entities tools to get information about which metrics, dimensions, and entities to use.
When using the order_by
parameter, you must ensure that the dimension or
entity also appears in the group_by
parameter. When fulfilling a lookback
query, prefer using order_by and limit instead of using the where parameter.
A lookback query requires that the order_by
parameter includes a descending
order for a time dimension.
The where
parameter should be database agnostic SQL syntax, however dimensions
and entity are referenced differently. For categorical dimensions,
use {{ Dimension('<name>') }}
and for time dimensions add the grain
like {{ TimeDimension('<name>', '<grain>') }}
. For entities,
use {{ Entity('<name>') }}
. When referencing dates in the where
parameter, only use the format yyyy-mm-dd
.
Don't call this tool if the user's question cannot be answered with the provided metrics, dimensions, and entities. Instead, clarify what metrics, dimensions, and entities are available and suggest a new question that can be answered and is approximately the same as the user's question.
For queries that may return large amounts of data, it's recommended to use a two-step approach:
First make a query with a small limit to verify the results are what you expect
Then make a follow-up query without a limit (or with a larger limit) to get the full dataset
Input Schema
Name | Required | Description | Default |
---|---|---|---|
group_by | No | ||
limit | No | ||
metrics | Yes | ||
order_by | No | ||
where | No |