Cara menggunakan dsum google sheets

The DSUM Google Sheets formula is almost similar to that of the SUM formula, but with a distinction. It gives us the sum of values available in a table like range, that meet a specified criteria. This is analogous to an SQL database sum query. The ‘D’ in the DSUM stands for ‘Database’, therefore, we can call this a Database SUM formula.

Syntax

DSUM(database, field, criteria)

  • database – is the reference to a structured data range that consists of labels, for each column, in the first row.
  • field – indicates the column on which the DSUM formula should sum the numeric values. This can be a text or a column index too.
  • criteria – this is a reference to a range that consists of criteria that the formula uses to filter the database values before counting.

Usage: DSUM Google Sheets formula

Let us assume that the below list of foods is our secret diet suggested by a nutritionist. We will try the formula out using a few examples.

We see that the data set is in a labeled tabular form spanning across cells A4 through to G13. And the criteria is keyed in the cells A1 through to G2.

Please note from the cases illustrated above that we can specify one or more criteria to filter the summing process. For example, the case in the row # 7 sums the values in the “Carbs (g)” column, subject to the criteria in the cell D2. Whereas the case in row # 11 sums the values from “Fat (g)” column, subject to the criteria within the cells C2 and D2. The last case on row # 12 includes all the criteria from A2 through to G2, and apparently there are two rows (9 & 10) that satisfies all of these conditions, hence the result 59.

The case on the row # 10 is a rather interesting one! We didn’t specify anything in the cell G2, yet, we gave that reference to the DSUM formula. The result is 40.5, because it summed everything in the “Fiber (g)” column as there is no criteria to filter out the rows.

Unwarranted Cases

Now, let us talk about pitfalls. Here is the first one, which we might already be aware of. Please consider the first case in the snapshot below.

Here, we tried summing non numeric values! Just like the SUM formula, DSUM formula sums only numbers. Therefore, it returned ‘0’ as output.

Here’s the second one in the image below.

Seemingly there’s nothing wrong with the formula this time but the result isn’t what we are expecting. The problem lies within the labels. Apparently, a missing or a mismatched label doesn’t help the DSUM formula, as its working hinges on the field name that the second parameter takes. Since the labels didn’t match, it returned the sum as zero.

Penggunaan REGEXMATCH

Ada banyak cara untuk melakukan ini di lembar Google. Satu adalah:

=SUM(filter(B:B,REGEXMATCH(A:A,"Joe|Roy")))

untuk membuatnya dengan sumif:

=SUMIF(ARRAYFORMULA(REGEXMATCH(A:A,"Joe|Roy")),true,B:B)

Filter dengan OR logika

dan rumus ini ok:

=sum(FILTER(B:B,(A:A="Joe")+(A:A="Roy")))

tetapi tidak begitu mudah digunakan ketika Anda menginginkannya cocok dengan lebih dari 2 nama.


fungsi DSUM

Untuk menjumlahkan beberapa kriteria, gunakan DSUM.

Siapkan data A1: B7:

Name    Sum
Joe       1
Joe       2
Tim       3
Roy       4
Tim       5
Roy       6

Siapkan rentang dengan kondisi D1: D3:

Name
Joe
Roy

Dan gunakan rumus DSUM:

=DSUM(A1:B7,B1,D1:D3)

Excel untuk Microsoft 365 Excel untuk Microsoft 365 untuk Mac Excel untuk web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 untuk Mac Excel 2016 Excel 2016 untuk Mac Excel 2013 Excel 2010 Excel 2007 Excel untuk Mac 2011 Excel Starter 2010 Lainnya...Lebih sedikit

Artikel ini menguraikan sintaks rumus dan penggunaan fungsi DSUM di Microsoft Excel.

Deskripsi

Menambahkan angka dalam bidang (kolom) rekaman dalam daftar atau database yang cocok dengan kondisi yang Anda ditentukan.

Sintaks

DSUM(database, field, criteria)

Sintaks fungsi DSUM memiliki argumen berikut:

  • Database    Diperlukan. Rentang sel yang membentuk daftar atau database. Database adalah daftar dari data yang terkait di mana baris-baris informasi terkait adalah rekaman, dan kolom-kolom data adalah bidang. Baris pertama daftar tersebut berisi label untuk masing-masing kolom.

  • Field    Diperlukan. Mengindikasikan kolom yang digunakan dalam fungsi tersebut. Masukkan label kolom yang dimasukkan di antara dua tanda kutip ganda, seperti "Umur" atau "Hasil," atau angka (tanpa tanda kutip) yang menyatakan posisi kolom di dalam daftar: 1 untuk kolom pertama, 2 untuk kolom kedua, dan seterusnya.

  • Criteria    Diperlukan. Adalah rentang sel berisi syarat yang Anda tentukan. Anda dapat menggunakan rentang untuk argumen kriteria, selama meliputi setidaknya satu label kolom dan setidaknya satu sel di bawah label kolom di mana Anda menentukan kondisi untuk kolom tersebut.

Keterangan

  • Anda dapat menggunakan rentang apa saja untuk argumen kriteria, selama meliputi setidaknya satu label kolom dan setidaknya satu sel di bawah label kolom di mana Anda menentukan kondisi untuk tersebut.

    Misalnya, jika rentang G1:G2 berisi label kolom Pendapatan dalam G1 dan jumlah $10.000 di G2, Anda dapat menetapkan rentang tersebut sebagai MatchIncome dan menggunakan nama itu sebagai argumen kriteria dalam fungsi database tersebut.

  • Meskipun rentang kriteria dapat ditempatkan di mana pun pada lembar kerja, jangan tempatkan rentang kriteria di bawah daftar tersebut. Jika Anda menambahkan lebih banyak informasi ke daftar, informasi baru itu ditambahkan ke baris pertama di bawah daftar tersebut. Jika baris di bawah daftar tersebut tidak kosong, Microsoft Excel tidak dapat menambahkan informasi baru itu.

  • Pastikan bahwa rentang kriteria tidak tumpang tindih dengan daftar.

  • Untuk melakukan operasi di seluruh kolom dalam suatu database, masukkan baris kosong di bawah label kolom dalam rentang kriteria tersebut.

Contoh

Salin contoh data di dalam tabel berikut ini dan tempel ke dalam sel A lembar kerja Excel yang baru. Agar rumus menunjukkan hasil, pilih datanya, tekan F2, lalu tekan Enter. Jika perlu, Anda bisa menyesuaikan lebar kolom untuk melihat semua data.

Pohon

Tinggi

Umur

Hasil

Laba

Tinggi

="=Apel"

>10

<16

="=Pir"

Pohon

Tinggi

Umur

Hasil

Laba

Apel

18

20

14

$105

Pir

1.2

1.2

10

$96

Ceri

1,3

14

9

$105

Apel

14

15

10

$75

Pir

9

8

8

$77

Apel

8

9

6

$45

Rumus

Deskripsi

Hasil

=DSUM(A4:E10,"Profit",A1:A2)

Total profit dari pohon apel (baris 5, 8, dan 10).

$225

=DSUM(A4:E10,"Profit", A1:F3)

Total profit dari pohon apel dengan tinggi antara 10 dan 16 kaki, serta semua pohon pir (baris 6, 8, dan 9).

$248

Atas halaman

Perlu bantuan lainnya?