Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Fungsi AVG menghitung nilai rata-rata kolom angka.
Sintaks
AVG(X)
Parameter
X - kolom atau ekspresi yang dievaluasi ke angka yang tidak teragregasi.
Cara kerja fungsi AVG
Fungsi AVG mengambil 1 parameter, yang harus berupa nama kolom angka, atau ekspresi angka. AVG menampilkan rata-rata untuk semua nilai kolom atau ekspresi tersebut.
Anda tidak dapat menerapkan fungsi ini ke kolom pra-agregasi (Agregasi sama dengan Auto), atau ke ekspresi yang merupakan hasil dari fungsi agregasi lainnya. Misalnya, formula seperti AVG(SUM(x)) akan menghasilkan error.
Contoh
Dalam contoh ini, parameter yang diteruskan ke AVG merupakan dimensi numerik yang tidak teragregasi (yaitu memiliki jenis AgregasiTidak Ada ).
Contoh formula
Input
Output
AVG(Latency)
0,02
0,07
0,09
0,06
AVG(CASE WHEN My Dimension < 1 THEN.5 WHEN My Dimension >= 1 AND My Dimension < 5 THEN 1 ELSE 2 END)
[[["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-30 UTC."],[],[],null,["# AVG\n\nThe `AVG` function calculates the average value of a numeric field.\n\nSyntax\n------\n\n`AVG(`\u003cvar translate=\"no\"\u003eX\u003c/var\u003e`)`\n\n### Parameters\n\n- \u003cvar translate=\"no\"\u003eX\u003c/var\u003e - a field or expression that evaluates to an unaggregated number.\n\nHow the `AVG` function works\n----------------------------\n\nThe `AVG` function takes 1 parameter, which must be the name of a numeric field, or a numeric expression. `AVG` returns the average for all values of that field or expression.\n\nYou can't apply this function to a pre-aggregated field (Aggregation equals `Auto`), or to an expression which is the result of another aggregation function. For example, a formula such as `AVG(SUM(x))` will produce an error.\n| **Note:** This function can be applied in one of the following ways:\n|\n| - In a data source, change a field's Aggregation to `Average`.\n| - In a report, [edit the field's aggregation](/looker/docs/studio/edit-fields-in-your-reports) in a chart.\n\nExamples\n--------\n\nIn these examples, the parameters passed to `AVG` are unaggregated numeric dimensions (i.e., they have an **Aggregation** type of **None** ).\n\nRelated resources\n-----------------\n\n- [Calculated fields](/looker/docs/studio/about-calculated-fields)\n- [Looker Studio function list](/looker/docs/studio/function-list)"]]