Thursday, 10 July 2014

Excel DCOUNTA Function

Microsoft Excel DCOUNTA Function

Basic Description

The Excel Dcounta function returns the number of non-blank cells, in a field (column) of a database for selected records only.
The records to be included in the count are those that satisfy a set of one or more user-specified criteria.
The function is very similar to the Excel Dcount function, the only difference being that the Dcounta function counts all non-blank cells where the Dcount function only counts cells containing numerical values.
The syntax of the Excel Dcounta function is :
DCOUNTA( database, [field], criteria )
where the arguments are shown in the table below:

database-A range of cells containing the database. The top row of the database should specify the field names.
[field]-An optional argument which specifies the field (column) within the database for which you want to return the count of non-blank cells.
This can either be a field number, or can be the field name (ie. the header in the top row of the database) encased in quotes (eg. "Gender", "Subject", etc)
If the [field] argument is omitted, the Dcounta function simply returns the count of all records that satisfy the supplied criteria.
criteria-A range of cells that contain the criteria, to specify which records should be included in the calculation.
The range can include one or more criteria, which are presented as a field name in one cell and the condition for that field in the cell below.
eg.
GenderAge
Male>8

Wildcards
You can also use the following wildcards in text-related criteria:
?    -    matches any single character
*    -    matches any sequence of characters
if you do actually want to find the ? or * character, type the ~ symbol before this character in your search.
eg. the condition "A*e" will match all cells containing a text string beginning with "A" and ending in "e".
The criteria supplied beneath each field heading can be either:
-a numeric value (including an integer, decimal, date, time, or logical value) (eg. 10, 01/01/2011, FALSE)
or
-a text string (eg. "Math", "Tuesday")
or
-an expression (eg. ">8", "<>0")

Note that the Excel database functions are not case sensitive. So, for example, the criteria ="Math" will be satisfied by cells containing the text "Math" or "math".

Excel Dcounta Function Examples

ABCDE
1NameGenderAgeSubjectScore
2AmyFemale8Math63%
3AmyFemale8English78%
4AmyFemale8Science39%
5BillMale8Math55%
6BillMale8English71%
7BillMale8Scienceawaiting
8SueFemale9Math
9SueFemale9English52%
10SueFemale9Science48%
11TomMale9Math78%
12TomMale9English69%
13TomMale9Science65%
The following examples are based on the simple database on the right, which stores the examination marks scored by four children in three different subjects.

Example 1

The example below uses the Dcounta function to count the number of Science examination scores recorded for male students. The criteria are specified in cells G1 - H2 and the Dcounta formula is shown in cell G3:
GH
1SubjectGender
2ScienceMale
3=DCOUNTA( A1:E13, "Score", G1:H2 )

The above Dcounta function finds that there are 2 rows for which the Gender is "Male" and the Subject is "Science". As the "Score" column for both of these rows is non-blank, the function returns the value 2
Note that, in the above example, the Dcounta function has counted cell E7, in which the Score field contains the text "awaiting". (This would have been excluded from the count if the Dcount function had been used instead of the Dcounta function).

Example 2

In the example below, the Dcounta function is used to find the number of Math examination scores recorded for females.
GH
1SubjectGender
2MathFemale
3=DCOUNTA( A1:E13, "Score", G1:H2 )

The above Dcounta function finds two rows for which the Subject is "Math" and the Gender is "Female". However, only one of these rows has a non-blank "Score", and so the function returns the value 1

Note that, in the above two examples, instead of typing in "Score" for the Field argument, we could have simply used the number 5 (to denote the 5th column of the database).

Example 3

In the example below, the Dcounta function is used to find the number of English examination scores that are higher than 60%.
In this case, the Field argument is omitted, so the Dcounta function simply counts all rows satisfying the supplied criteria:
GH
1SubjectScore
2English>60%
3=DCOUNTA( A1:E13,   , G1:H2 )

The above Dcounta function finds three rows for which the Subject is "English" and the Score is greater than 60%. The function therefore returns the count 3

No comments:

Post a Comment