Stay organized with collectionsSave and categorize content based on your preferences.
TheCOUNTfunction counts the number of items in a field.
Syntax
COUNT(X)
Parameters
X- a field or expression that contains the items to be counted.
How theCOUNTfunction works
TheCOUNTfunction takes one parameter, which can be the name of a metric, dimension, or an expression of any type.COUNTreturns the total number of items in that field or expression, including duplicates.
To count only unique items, useCOUNT_DISTINCTorAPPROX_COUNT_DISTINCT.
There are 2 other ways to apply this function:
In a data source, change a field'sAggregationtype toCount.
COUNT(Page)- counts the number of non-unique values in thePagedimension.
Limits ofCOUNT
You can't apply this function to a pre-aggregated field (Aggregationtype ofAuto), or to an expression which is the result of another aggregation function. For example, a formula such asCOUNT(SUM(x))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-07-22 UTC."],[],[],null,["# COUNT\n\nThe `COUNT` function counts the number of items in a field.\n\nSyntax\n------\n\n`COUNT( `\u003cvar translate=\"no\"\u003eX\u003c/var\u003e` )`\n\n### Parameters\n\n- \u003cvar translate=\"no\"\u003eX\u003c/var\u003e - a field or expression that contains the items to be counted.\n\nHow the `COUNT` function works\n------------------------------\n\nThe `COUNT` function takes one parameter, which can be the name of a metric, dimension, or an expression of any type. `COUNT` returns the total number of items in that field or expression, including duplicates.\n\nTo count only unique items, use `COUNT_DISTINCT` or `APPROX_COUNT_DISTINCT`.\n\u003e There are 2 other ways to apply this function:\n\u003e\n\u003e - In a data source, change a field's **Aggregation** type to `Count`.\n\u003e - in a report, [edit the field's aggregation](/looker/docs/studio/edit-fields-in-your-reports) in a chart.\n\nExamples\n--------\n\n`COUNT(Page)` - counts the number of non-unique values in the **Page** dimension.\n\nLimits of `COUNT`\n-----------------\n\nYou can't apply this function to a pre-aggregated field ( **Aggregation** type of **Auto** ), or to an expression which is the result of another aggregation function. For example, a formula such as `COUNT(SUM(x))` 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)"]]