%%[ SET @city=City SET @rows=LookupRows("AMPscript - Day 11 Summer_Trails", "City", @city) SET @rowcount= RowCount(@rows) IF @rowcount > 0 THEN SET @range = Random(1, @rowcount) SET @trail = Field(Row(@rows, @range), "Trail") Else SET @rows1=LookupRows("AMPscript - Day 11 Summer_Trails", "City", "Boston") SET @trail = Field(Row(@rows1, 1), "Trail") ENDIF ]%%
Data Extension Import – when importing data to a data extension, if a primary key is selected and multiple rows of data with the same primary exist, only one of the rows will be imported. Thus if the Record Count is lower than it’s supposed to be, double-check on the primary key field to see if more than one row has the same value. The fix is to delete the Data Extension and recreate it without any primary key specified, then during importing select the Import Type as Overwrite. This way Marketing Cloud allows importing data to a Data Extension without having to specify a primary key.
Due to the sample data file not containing an event for the city of New York, I included an Else clause to address it so that it will display the event from Boston instead of an empty value.