Runtime verified Test scripts included

Syntax

DataExtensionRowCount(dataExtensionName)  →  number
1 argument — exactly

Parameters

Name Type Required Description
dataExtensionName string Yes Name or external key of the data extension to count

Example

%%[
  VAR @total
  SET @total = DataExtensionRowCount("AMP_VERIFY_SCRATCH")
]%%
Rows: %%=v(@total)=%%

With three seeded rows, renders Rows: 3.

Unlike RowCount, it takes the data extension by name and needs no prior lookup, so it is a one-line total:

Subscribers: %%=v(DataExtensionRowCount("AMP_VERIFY_SCRATCH"))=%%

Return value

number — the total number of rows currently stored in the named data extension.

There is no sentinel: the result is a bare non-negative integer.

Behaviour

Counts every row in the data extension by name. After seeding three rows, DataExtensionRowCount("AMP_VERIFY_SCRATCH") returned 3. It is addressed by data extension name or external key — no rowset and no filter, so it counts the whole table rather than a matched subset.

Show test script
%%[
  VAR @b
  SET @b = RequestParameter("b")

  IF @b == "zzz" THEN
    OutputLine(Concat("CTRL=[alive]"))
  ENDIF

  IF @b == "safe" THEN
    DeleteData("AMP_VERIFY_SCRATCH", "Id", "A1")
    DeleteData("AMP_VERIFY_SCRATCH", "Id", "A2")
    DeleteData("AMP_VERIFY_SCRATCH", "Id", "A3")
    InsertData("AMP_VERIFY_SCRATCH", "Id", "A1", "FirstName", "Alice")
    InsertData("AMP_VERIFY_SCRATCH", "Id", "A2", "FirstName", "Bob")
    InsertData("AMP_VERIFY_SCRATCH", "Id", "A3", "FirstName", "Alice")

    /* total rows in the DE, addressed by name/key */
    OutputLine(Concat("DataExtensionRowCount=[", DataExtensionRowCount("AMP_VERIFY_SCRATCH"), "]"))
  ENDIF
]%%

Availability

Platform Available
Marketing Cloud Engagement Yes
Marketing Cloud Next Check the official reference

See also