Marketing Console Users Guide

Cheetah Digital Loyalty Phoenix UDF Guide

1. in_period()

Checks if the given date is within the evaluated period based on the given expression.

SELECT count(*)
FROM ACTIVITY_TABLE 
WHERE in_period(sl_activity_ts, 'last1m') = TRUE 

2. age()

Computes the age of the given date with respect to the current date.

SELECT count(*)
FROM MEMBER_TABLE
WHERE age(member_since, 'month') < 1 

3. get_age_group()

SELECT get_age_group(birthdate) AS "Age Group", 
       count(*) 
FROM MEMBER_TABLE 
GROUP BY "Age Group"

4. get_engagement_level()

Matches the given integer/count to an engagement level/grouping

SELECT current_tier AS "Tier",
       get_engagement_level(count(*))
FROM MEMBER_TABLE 
GROUP BY "Tier" 

5. sl_sign()

Based on the earn_type, a positive or negative multiplier is returned

SELECT SUM(sl_sign(earn_type) * %PrimaryMetric) AS "Balance"
FROM ACTIVITY_TABLE

6. get_region()

Get the region of the state.

SELECT get_region(mailing_state) AS "Region",
       count(*) 
FROM MEMBER_TABLE
GROUP BY "Region" 

7. get_all_time_balance()

Takes a decimal array whose size is 3, as parameter. It computes the all-time balance while assuming that the first element if the all-time earn value, the second element is the all-time redeem value, and the third element is the all-time expire value.

SELECT SUM(COALESCE(get_all_time_balance(points),0)) AS "Balance" 
FROM MEMBER_TABLE