Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Fungsi COUNT menghitung jumlah item dalam kolom.
Sintaks
COUNT( X )
Parameter
X - kolom atau ekspresi yang berisi item yang akan dihitung.
Cara kerja fungsi COUNT
Fungsi COUNT mengambil satu parameter, yang dapat berupa nama metrik, dimensi, atau ekspresi dari jenis apa pun. COUNT menampilkan total jumlah item dalam kolom atau ekspresi tersebut, termasuk duplikat.
Untuk menghitung hanya item unik, gunakan COUNT_DISTINCT atau APPROX_COUNT_DISTINCT.
Ada 2 cara lain untuk menerapkan fungsi ini:
Di sumber data, ubah jenis Agregasi kolom ke Count.
COUNT(Page) - menghitung jumlah nilai non-unik dalam dimensi Halaman.
Batas COUNT
Anda tidak dapat menerapkan fungsi ini ke kolom pra-agregasi ( jenis AgregasiOtomatis), atau ke ekspresi yang merupakan hasil dari fungsi agregasi lainnya. Misalnya, formula seperti COUNT(SUM(x)) akan menghasilkan error.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-31 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)"]]