I'm trying to pull certain values from a DE depending on the Subscriber location. Please see below for details:
Data extension 01 - "SubscriberList" (to use for sending):
SubscriberKey | Location | Name | Email
=================================================
SK01 | Melbourne | Bill | [email protected]
SK02 | Sydney | Jane | [email protected]
SK03 | Newcastle | Tom | [email protected]
SK04 | null | Amy | [email protected]
SK05 | Perth | Ted | [email protected]
Data extension 02 - "NewsletterContent":
Category | Location | Heading | Text
News | Melbourne | NewsTitle01 | NewsContent01<
News | Sydney Perth | NewsTitle02 | NewsContent02
News | Null | NewsTitle03 | NewsContent03
Events | Newcastle | EventsTitle01 | EventsContent01
Events | Brisbane | EventsTitle02 | EventsContent02
Events | Sydney | EventsTitle03 | EventsContent03
Current AMPScript:
%%[
var @rows, @row, @rowCount, @Category, @i
set @Category = AttributeValue("Category")
set @Category = "News"
set @rows = LookupRows("NewsletterContent","Category", @Category)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
for @i = 1 to @rowCount do
var @Heading, @Text
set @row = row(@rows, @i)
set @Heading = field(@row,"Heading")
set @Text = field(@row,"Text")
]%%
%%=v(@Heading)=%%
%%=v(@Text)=%%
%%[
next @i ]%%
%%[ else ]%%
%%[ endif ]%%
Current output:
NewsTitle01
NewsContent01
NewsTitle02
NewsContent02
NewsTitle03
NewsContent03
Requirements:
- Since I’ve set the category as “News”, it’s only pulling News values from NewsletterContent. Is there any way I could make it so that it pulls “Events” values as well?
- Current output pulls all the data that is in NewsletterContent. I am trying to refine it so that the relevant content is displayed depending on the subscriber’s location. For example:
- If Location = Sydney in SubscriberList, News and Events content in NewsletterContent for Sydney is displayed.
- Where NewsletterContent location is null, the content gets displayed for all subscribers regardless of their location.
How would I go about doing all of the above?
Thank you in advance!