# Query Metric

```
POST 
/v1/datasets/metrics/query
```

Compute a metric from its stored definition, on the rows you may read.

The server compiles the definition (its expression, its default filters, your time range, grain, dimensions and filters) into one SELECT over the metric's dataset and runs it through the same lane as `POST /v1/query`, as you: your row rules, your group's and your key's bindings apply, and the read is recorded on your credential. Two members with different row rules get two different, correct numbers.

* `metric` is a name from `list_metrics`; `datasetId` is needed only when two datasets you can view define that name (409 `metric_ambiguous` names them).
* `version` pins the definition: when the metric has moved on, the call is refused (409 `metric_version_changed`, with the current version) instead of answering with a definition you did not mean.
* `grain` (`day`, `week`, `month`, `quarter`, `year`) needs a time column; `timeRange.start` is inclusive and `timeRange.end` exclusive.
* `dimensions` and `filters` name DECLARED dimensions only; filter values are bound as literals. At most 10,000 result rows.

Returns `value` (no grain and no dimensions) or `columns` + `rows`, the definition used (`metric`: name, label, definition, expr, filters, status, version, caveats), `rowScope`, `rowPolicyApplies`, `freshness` (`asOf`, `provisionalFrom` from the dataset's declared lateness) and the compiled `sql`. Refusals of the query lane answer exactly as `POST /v1/query` does.

## Request[​](#request "Lien direct vers request")

## Responses[​](#responses "Lien direct vers Responses")

* 200
* 404
* 422

Successful Response

Not found

Validation Error
