Salesforce Marketing Cloud AMPscript Guide: IIF() & IF-ELSE with Real-Time Business Use Cases
Use Case 1: Personalized Greeting Using IIF() What is the Business Requirement? A company wants to personalize email greetings based on the subscriber's gender. Male subscribers should see Mr. Female subscribers should see Ms. Instead of writing a full IF-ELSE block, we can use the IIF() function to return a value directly. Algorithm START Read Gender IF Gender = Male Display Mr. ELSE Display Ms. END END IIF Syntax IIF(condition, value_if_true, value_if_false) AMPscript Code %%[ VAR @Gender,@Greeting SET @Gender = AttributeValue("Gender") SET @Greeting = IIF(@Gender == "Male","Mr.","Ms.") ]%% %%=v(@Greeting)=%% Expected Output Record 1 Gender = Male Output Mr. Record 2 Gender = Female Output Ms. Use Case 2: Loyalty Member Classification Using IIF() What is the Business Requirement? A company has a loyalty program and wants to display different benefits based on the customer's membership status. Gold Members → Premium...