How to use the DMAX function
What is the DMAX function?
The DMAX function extracts the largest (maximum) number from a column in a database whose records match a condition or criteria.
1. Introduction
What is DMAX an abbreviation of?
DMAX is an abbreviation of Database Max.
What is a database in this context?
Excel defines a database as a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
Where can you place the criteria range?
You can place your criteria range wherever you want on your worksheet, however, it is not recommended below the list/database. The function needs a blank row below the list to work properly.
What criteria characters are allowed?
Allowed criteria range characters are less than and greater than signs <>, use them to specify a criteria range. Also, asterisks * can be used to match partial strings.
Does the DMAX function ignore blank cells, boolean, and text values?
Yes, blank cells, boolean values and text values are ignored.
Does the DMAX function ignore error values?
No, the DMAX function does not ignores error values.
What is the difference between the DMAX function and the MAX function?
The DMAX function calculates the largest number based on a condition or criteria in a list/database whereas the MAX function calculates the largest number without using a condition/criteria.
How to include the entire database in the calculation?
To include the entire list/database enter a blank line below the criteria range column labels. In other words, don't specify any criteria.
2. Syntax
DMAX(database, field, criteria)
database | Required. The cell reference to a list or database. |
field | Required. The field argument lets you choose which column to use. You can use the column name enclosed with double quotation marks or the corresponding column number. |
criteria | Required. A cell reference to the criteria range. The criteria range needs to have column labels and at least one condition below the column label. |
3. Example 1
In a sales database, you want to get the largest sales number from column "Number" where the "Size" column is equal to "L". How can you use the DMAX function to get this value?
The data is in cell range B6:D12 in the image above, here is that data:
Item | Size | Number |
A102 | M | 370 |
A103 | L | 690 |
A099 | S | 310 |
A412 | S | 190 |
A341 | L | 550 |
A340 | M | 730 |
The criteria are in cell range B2:C3:
Size |
L |
The arguments are:
database = B6:D12
field = 3
criteria = B2:B3
Formula in cell B15:
The formula gets the largest number from column 3 (D) with the condition that the size is L. The maximum number of 690 and 550 is 690 which is returned in cell B15.
4. Example 2
This example demonstrates AND logic between conditions.
In a sales database, you want to get the largest sales number from column "Number" where the "Size" column is equal to "L", the "Number" values must be smaller than 650. How can you use the DMAX function to get this value?
The data is in cell range B6:D12 in the image above, here is that data:
Item | Size | Number |
A102 | M | 370 |
A103 | L | 690 |
A099 | S | 310 |
A412 | S | 190 |
A341 | L | 550 |
A340 | M | 730 |
The criteria are in cell range B2:D3:
Item | Size | Number |
L | <650 |
The arguments are:
database = B6:D12
field = 3
criteria = B2:D3
Formula in cell B15:
The formula gets the largest number from column 3 (D) with the condition that the size is L and the condition that the number is smaller than 650. Both these criteria must match, in other words, AND logic is applied. The maximum number is 550 which is returned in cell B15.
5. Example 3
This example demonstrates the asterisk which is a wildcard character. It matches 0 (zero) to any number of characters.
In a sales database, you want to get the largest sales number from column "Number" where the "Item" column begins with "A". How can you use the DMAX function to get this value?
The data is in cell range B6:D12 in the image above, here is that data:
Item | Size | Number |
A102 | M | 370 |
A103 | L | 690 |
A099 | S | 310 |
A412 | S | 190 |
A341 | L | 550 |
B340 | M | 730 |
The criteria are in cell range B2:D3:
Item | Size | Number |
A* |
The arguments are:
database = B6:D12
field = 3
criteria = B2:D3
Formula in cell B15:
The formula gets the largest number from column 3 (D) with the condition that the Item begins with "A". The maximum number is 690 which is returned in cell B15. Number 730 is the largest value, however it the Item value doesn't begin with an "A".
6. Example 4
This example demonstrates how to perform OR logic between conditions. You accomplish this by specifying the conditions on a row each.
In a sales database, you want to get the largest sales number from column "Number" where the "Size" column equals "M" or "L". How can you use the DMAX function to get this value?
The data is in cell range B6:D12 in the image above, here is that data:
Item | Size | Number |
A102 | M | 370 |
A103 | L | 690 |
A099 | S | 310 |
A412 | S | 190 |
A341 | L | 550 |
A340 | M | 730 |
The criteria are in cell range B2:D3:
Item | Size | Number |
M | ||
L |
The arguments are:
database = B6:D12
field = 3
criteria = B2:D3
Formula in cell B15:
The formula gets the largest number from column 3 (D) with the condition that the Size is "M" or "L". The values that match these two conditions are 370, 690, 550, and 730. The maximum number is 730 which is returned in cell B15.
7. Example 5
This example demonstrates how to use the question mark which is a wildcard character. The question mark matches a single character.
In a sales database, you want to get the largest sales number from column "Number" where the "Item" column has "1" as the second character, the total character length must be 4. How can you use the DMAX function to get this value?
The data is in cell range B6:D12 in the image above, here is that data:
Item | Size | Number |
A102 | M | 370 |
A103 | L | 690 |
A099 | S | 310 |
A412 | S | 190 |
A341 | L | 550 |
A340 | M | 730 |
The criteria are in cell range B2:D3:
Item | Size | Number |
?1?? |
The arguments are:
database = B6:D12
field = 3
criteria = B2:D3
Formula in cell B15:
The formula gets the largest number from column 3 (D) with the condition that the second character in the value from the Item column is "1". The values that match these two conditions are 370 and 690. The maximum number is 690 which is returned in cell B15.
Functions in 'Database' category
The DMAX function function is one of 11 functions in the 'Database' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form