Database functions

DGET

Matches all 3 recorded answers

Recorded: 3 workbook cells. How we measure this · See the Rust code

Local names in 40 languages
LanguageName in Excel
ArabicDGET
BulgarianDGET
CzechDGET
DanishDHENT
GermanDGET
GreekDGET
English (Australia)DGET
English (United Kingdom)DGET
English (United States)DGET
SpanishBDEXTRAER
EstonianDGET
FinnishTNOUDA
FrenchBDLIRE
HebrewDGET
CroatianDGET
HungarianAB.MEZŐ
IndonesianDGET
ItalianDGET
JapaneseDGET
KoreanDGET
LithuanianDGET
LatvianDGET
NorwegianDGET
DutchDBLEZEN
PolishBD.POLE
Portuguese (Brazil)DGET
Portuguese (Portugal)BDOBTER
RomanianDGET
RussianБИЗВЛЕЧЬ
SlovakDGET
SlovenianDGET
Serbian (Latin)DGET
SwedishDHÄMTA
ThaiDGET
TurkishVAL işlevi
UkrainianDGET
VietnameseDGET
Chinese (Simplified)DGET
Chinese (Hong Kong)DGET
Chinese (Traditional)DGET

Names from Microsoft's support site.

What it does

DGET(database, field, criteria)

DGET(database, field, criteria) selects the records of database that satisfy criteria and returns the value held in the column named by field — but only if exactly one record matches.

|R| = 0  →  #VALUE!
|R| = 1  →  the value of cell (the matching record, field column)
|R| > 1  →  #NUM!

The uniqueness requirement is the point of the function. DGET is a lookup that refuses to guess: where VLOOKUP silently returns the first of several matches, DGET reports that the question was ambiguous.

The selection stage — header matching, AND across a criteria row, OR down the rows, blank criteria cells, and criteria-expression parsing — is identical for all twelve database functions and is explained once in the criteria-range mechanism.

Arguments

Three arguments, all required at the call site; the reference implementation declares an arity of exactly 3.

  • database — the header-plus-records range or array.
  • field — the column selector, as header text or as a 1-based column index within the database range. Required: unlike DCOUNT and DCOUNTA, DGET has nothing to return without a column.
  • criteria — the header-plus-conditions range or array. Note the family rule that bites hardest here: a criteria range with no condition rows, or with an all-blank condition row, selects every record — so on any database with two or more records that mistake produces #NUM!, not the "first record" a reader might expect.

Try it

Input cells (optional)

Example: {"B2": 3, "B3": 4}. A1 holds the formula. Other cells need values before a formula can read them.

Enter a formula, then calculate.

Runs locally in your browser with OneCalc. Its answer may differ from Excel. Use English function names and commas between arguments.

Quirks

Result and edge cases

Returns whatever kind the selected cell holds: Number, Text, or Logical.

  • The selected cell holds an error value: that error is returned. DGET passes the cell through rather than diagnosing it.
  • Text is returned as text. DGET is the only family member that can return a non-numeric result, which matters when its output feeds arithmetic downstream.
  • Arrays: inline array literals resolve to grids and are accepted; DGET is not a lift kernel, and it never returns an array.

Errors

ErrorCondition
#VALUE!No record matches the criteria
#NUM!More than one record matches the criteria
#VALUE!database or criteria is not a grid or is empty; a database header cell is blank; a criteria header names no database field; field matches no header, or is a non-integer or out-of-range column index
propagatedAn error value in a header cell or a criteria cell surfaces as that error; an error value in the selected cell is returned as the function's result

How to implement

Notes for implementers

  1. Count matches before reading any cell. The uniqueness test governs the whole result, and an implementation that reads the first match eagerly will produce a value where an error is required.
  2. The two error codes are not interchangeable and are not #N/A. Getting the pair backwards is a silent semantic bug: both are errors, so a naive test that only checks ISERROR will not catch it.
  3. Numeric criteria comparison is not exact double comparison — see the note in the shared mechanism. For DGET the consequence is sharper than for the aggregates: a tolerant comparison can turn a unique match into a double match, converting a value into #NUM!.

Rust code

Show the CalcFunc source of this function

Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.

DGET · 1 lines · calc-func/src/catalogue/database.rs on GitHub
4 dget "DGET" (3, 3) [R "database", V "field", R "criteria"] |s, a, sv| { database(s, a, sv, Kind::Get) }

Kernels shared with other functions

Argument and result plumbing

No implementation has been published with a Handbook test suite for this function.

Version differences

No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.

Alternatives

Relationships

  • Siblings: the other eleven database functions, which share the selection stage and reduce the field column instead of selecting from it. Where they answer "how much", DGET answers "which".
  • Nearest modern equivalents: XLOOKUP and FILTER. FILTER is the closest in spirit — criteria in, records out — but returns every match as a spilled array rather than insisting on uniqueness. XLOOKUP returns the first match and takes a not-found argument. Neither supersedes DGET; Excel retains all three.
  • Confused with: VLOOKUP and INDEX/MATCH, both of which return the first match without complaint. Replacing DGET with VLOOKUP to "fix" a #NUM! discards the very check that was reporting a real ambiguity in the data.

Named variants

No named variants are recorded yet.

Suggest a correction or contribute an implementation · For agents