0

Is it possible to convert semi-colon separated values into a list using AMP Script like the example below:

Structure in the data extension tab: 1 Orange ;2 Apples ;3 Peaches ;5 Plums

Expected Output:

  • 1 Orange
  • 2 Apples
  • 3 Peaches
  • 5 Plums
1

1 Answer 1

2

You can do it using the BuildRowsetFromString function:

%%[

set @list = "1 Orange;2 Apples;3 Peaches;5 Plums"

set @rows = BuildRowsetFromString(@list,";")
set @rowCount = rowCount(@rows)

if @rowCount > 0 then

  for @i = 1 to @rowCount do

    set @row = row(@rows, @i) /* get row based on counter */
    set @fruit = field(@row,1)

    ]%%

    <br>Row %%=v(@i)=%%, fruit: %%=v(@fruit)=%%

    %%[

  next @i ]%%

%%[ else ]%%

No rows found

%%[ endif ]%%

Not the answer you're looking for? Browse other questions tagged .