Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
APPROX_COUNT_DISTINCT
Fungsi APPROX_COUNT_DISTINCT menghitung perkiraan jumlah item unik dalam kolom.
Sintaks
APPROX_COUNT_DISTINCT(X)
Parameter
field_expression - kolom atau ekspresi yang berisi item yang akan dihitung.
Cara kerja fungsi APPROX_COUNT_DISTINCT
Fungsi APPROX_COUNT_DISTINCT mengambil satu parameter, yang dapat berupa nama metrik, dimensi, atau ekspresi dari jenis apa pun. APPROX_COUNT_DISTINCT menampilkan perkiraan jumlah item unik dalam kolom atau ekspresi tersebut.
APPROX_COUNT_DISTINCT lebih efisien dalam hal pemrosesan kueri daripada COUNT_DISTINCT, tetapi menampilkan hasil yang kurang tepat. Jika set data Anda sangat besar, atau jika performa laporan Anda lebih penting daripada jumlah yang tepat, pertimbangkan untuk menggunakan APPROX_COUNT_DISTINCT. Menggunakan APPROX_COUNT_DISTINCT, bukan COUNT_DISTINCT, juga dapat membantu mengurangi biaya kueri saat menggunakan sumber data BigQuery.
Untuk penjelasan mendalam tentang cara kerja perkiraan agregasi, lihat dokumentasi BigQuery.
Contoh
APPROX_COUNT_DISTINCT(Page) - menghitung perkiraan jumlah nilai unik dalam dimensi Halaman.
Batas APPROX_COUNT_DISTINCT
Fungsi APPROX_COUNT_DISTINCT hanya tersedia saat digunakan dengan sumber data BigQuery.
Untuk sumber data yang tidak mendukung APPROX_COUNT_DISTINCT, APPROX_COUNT_DISTINCT akan berfungsi seperti COUNT_DISTINCT.
Anda tidak dapat menerapkan fungsi ini untuk metrik pra-agregasi ( jenis AgregasiOtomatis), atau untuk ekspresi yang merupakan hasil dari fungsi agregasi lainnya. Misalnya, formula seperti APPROX_COUNT_DISTINCT(Sessions) di sumber data Google Analytics 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-09-04 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)"]]