DataExtensionRowCount
Returns the total number of rows in a data extension. Runtime-proven on a live Marketing Cloud Engagement CloudPage.
Syntax
DataExtensionRowCount(dataExtensionName) → number
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
]%%
OutputLine given a bare string literal renders an empty line. Wrap the argument in Concat() or your start and done markers vanish silently — which looks exactly like the function failing.
Availability
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes |
| Marketing Cloud Next | Check the official reference |
See also
RowCount— counts the rows in a rowset rather than a whole data extensionLookupRows— read a filtered subset of the same data extension- Official reference · ampscript.guide