Runtime verified Test scripts included

Syntax

RowCount(rowset)  →  number
1 argument — exactly

Parameters

Name Type Required Description
rowset rowset Yes A rowset from LookupRows, LookupOrderedRows, ExecuteFilter, or a BuildRowsetFrom* function

Example

%%=RowCount(BuildRowSetFromString("a::b::c", "::"))=%%

Renders 3.

Because an empty rowset gives 0 rather than an error, it is the guard to use before reading a row:

%%[
  SET @rows = RetrieveSalesforceObjects("Contact", "Id", "IsDeleted", "=", "false")
  IF RowCount(@rows) > 0 THEN
    SET @idLength = Length(Field(Row(@rows, 1), "Id"))
  ENDIF
]%%
%%=v(@idLength)=%%

Renders 18.

Return value

number — how many rows the rowset holds, 0 for an empty one.

Behaviour

Counts the rows. RowCount(BuildRowSetFromString("a::b::c", "::")) gives 3; a multi-character delimiter works.

A string without the delimiter is one row. RowCount(BuildRowSetFromString("NoDelimiterHere", ",")) gives 1.

An empty rowset gives zero. RowCount on BuildRowsetFromJSON("[]", "$[*]", 1) renders 0, and so does RowCount on a RetrieveSalesforceObjects query that matches no record. Neither fails.

Show Next test script
<!-- Marketing Cloud Next test script for RowCount. Paste it into the HTML component of a
     Next email and open the preview. Each line prints the result Next gave when the call
     was rendered on its own (expect) next to the result of this run (got).
     Assembled from single-call test emails (dates on the page); it has not been
     run as one email. Calls that make Next fail are listed separately. -->
<p>c1 expect=[3] got=[%%=RowCount(BuildRowSetFromString("a::b::c","::"))=%%]</p>
<p>c2 expect=[1] got=[%%=RowCount(BuildRowSetFromString("NoDelimiterHere",","))=%%]</p>
<p>c3 expect=[0] got=[%%[ SET @c1rs = BuildRowsetFromJSON("[]", "$[*]", 1) ]%%%%=RowCount(@c1rs)=%%]</p>

Availability & differences

PlatformAvailable
Marketing Cloud EngagementYes
Marketing Cloud NextYes, from API 67.0
Same in Marketing Cloud Engagement

Engagement gives the same counts: 3 for a split string, 1 for a string without the delimiter and 0 for an empty rowset. Compared 2026-11-23 by rendering the same calls in a Marketing Cloud Next email.

See also