Stay organized with collections
Save and categorize content based on your preferences.
APPROX_COUNT_DISTINCT
The APPROX_COUNT_DISTINCT function counts the approximate number of unique items in a field.
Syntax
APPROX_COUNT_DISTINCT(X)
Parameters
field_expression - a field or expression that contains the items to be counted.
How the APPROX_COUNT_DISTINCT function works
The APPROX_COUNT_DISTINCT function takes one parameter, which can be the name of a metric, dimension, or expression of any type. APPROX_COUNT_DISTINCT returns the approximate number of unique items in that field or expression.
APPROX_COUNT_DISTINCT is more efficient in terms of query processing than COUNT_DISTINCT, but returns less exact results. If your dataset is very large, or if the performance of your report is more important than exact counts, consider using APPROX_COUNT_DISTINCT. Using APPROX_COUNT_DISTINCT instead of COUNT_DISTINCT can also help reduce query costs when using BigQuery data sources.
For an in-depth explanation of how approximate aggregation works, see the BigQuery documentation.
Example
APPROX_COUNT_DISTINCT(Page) - counts the approximate number of unique values in the Page dimension.
Limits of APPROX_COUNT_DISTINCT
The APPROX_COUNT_DISTINCT function is available only when used with BigQuery data sources.
For data sources which don't support APPROX_COUNT_DISTINCT, APPROX_COUNT_DISTINCT will act like COUNT_DISTINCT.
You can't apply this function to a pre-aggregated metric ( Aggregation type of Auto ), or to an expression that is the result of another aggregation function. For example, a formula such as APPROX_COUNT_DISTINCT(Sessions) in a Google Analytics data source will produce an error.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 UTC."],[],[],null,["APPROX_COUNT_DISTINCT\n=====================\n\nThe `APPROX_COUNT_DISTINCT` function counts the approximate number of unique items in a field.\n| **Note:** `APPROX_COUNT_DISTINCT` is available only when your data comes from a BigQuery data source. For other data source types, use `COUNT_DISTINCT`.\n\nSyntax\n------\n\n`APPROX_COUNT_DISTINCT(`\u003cvar translate=\"no\"\u003eX\u003c/var\u003e`)`\n\n### Parameters\n\n- \u003cvar translate=\"no\"\u003efield_expression\u003c/var\u003e - a field or expression that contains the items to be counted.\n\nHow the `APPROX_COUNT_DISTINCT` function works\n----------------------------------------------\n\nThe `APPROX_COUNT_DISTINCT` function takes one parameter, which can be the name of a metric, dimension, or expression of any type. `APPROX_COUNT_DISTINCT` returns the approximate number of unique items in that field or expression.\n\n`APPROX_COUNT_DISTINCT` is more efficient in terms of query processing than `COUNT_DISTINCT`, but returns less exact results. If your dataset is very large, or if the performance of your report is more important than exact counts, consider using `APPROX_COUNT_DISTINCT`. Using `APPROX_COUNT_DISTINCT` instead of `COUNT_DISTINCT` can also help reduce query costs when using BigQuery data sources.\n\nFor an in-depth explanation of how approximate aggregation works, see the [BigQuery documentation](/bigquery/docs/reference/standard-sql/approximate_aggregate_functions).\n\nExample\n-------\n\n\u003e `APPROX_COUNT_DISTINCT(`\u003cvar translate=\"no\"\u003ePage\u003c/var\u003e`)` - counts the approximate number of unique values in the **Page** dimension.\n\nLimits of `APPROX_COUNT_DISTINCT`\n---------------------------------\n\n- The `APPROX_COUNT_DISTINCT` function is available only when used with BigQuery data sources.\n\n- For data sources which don't support `APPROX_COUNT_DISTINCT`, `APPROX_COUNT_DISTINCT` will act like `COUNT_DISTINCT`.\n\n- You can't apply this function to a pre-aggregated metric ( **Aggregation** type of **Auto** ), or to an expression that is the result of another aggregation function. For example, a formula such as `APPROX_COUNT_DISTINCT(Sessions)` in a Google Analytics data source will produce an error.\n\nRelated resources\n-----------------\n\n- [Calculated fields](/looker/docs/studio/about-calculated-fields)\n- [Looker Studio function list](/looker/docs/studio/function-list)"]]