Conditions


This section provides examples of creating segments based on various conditions.

Condition is a child element of the request which should be sent to the Segmentation Service. All examples below should be considered as a part of the following request, where CONDITION_PLACE_HOLDER (line 7) should be filled with the proper condition type:

NOTE: In case of some more complicated conditions be aware that condition contains childCondition (Loyalty Account) or even childConditions (Logical).

Condition 1: Age

Compares the number of years elapsed from the specific date with the given value.

Parameters

ParametersDescription
columnNameColumn based on which the age will be calculated. This column must have a date or datetime data type.
ageCalculationType- ExactDate - Age is calculated based on the number of years elapsed from the precise date stored in the specified column.
- YearOnly - Age is calculated using the calendar years. Hence, its value changes only at the turn of the year.
operatorOperator used to compare the values.
The allowed values are EqualOrSmaller, EqualOrGreater, Equal, NotEqual.
ageValue with which calculated age will be compared.

Example

Include customers with age greater or equal to 18:

Condition 2: AnniversaryIsOnDayOfMonth

Compares day and month at which some event took place with specified values.

Parameters

ParametersDescription
columnNameColumn that will be compared with the specified parameters. This column must have a date or datetime data type.
dayDay compared with the day value stored in the column.
monthMonth compared with the month value stored in the column.

Example

Include customers born on the 15th of March:

Condition 3: AnniversaryIsThisMonth

Checks if the anniversary of some event occurs in the current month.

Parameters

ParametersDescription
columnNameColumn value that will be compared with the current month. This column must have a date or datetime data type.

Example

Include customers who have a birthday this month:

Condition 4: AnniversaryIsThisWeek

Checks if the anniversary of some event occurs in the current week.

Parameters

ParametersDescription
columnNameColumn value that will be compared with the current week. This column must have a date or datetime data type.

Example

Include customers who have a birthday this week:

Condition 5: AnniversaryIsToday

Checks if the anniversary of some event occurs today.

Parameters

ParametersDescription
columnNameColumn value that will be compared with the current day. This column must have a date or datetime data type.

Example

Include customers who have a birthday today:

Condition 6: AnniversaryIsWithin

Checks if the anniversary of the given date occurs within the last or the next number of days from today.

Parameters

ParametersDescription
columnNameColumn value that will be compared with specified criteria. This column must have a date or datetime data type
operatorSpecified if we compare with past or next days. The allowed values are FutureDays or PastDays.
numberOfDaysNumber of days within which the anniversary must take place — either in past or in the future depending on the value of the operator parameter.

Example

Include customers who have a birthday today or in the last seven days:

Condition 7: AttributeDictionary

Condition used only for customer attributes. Checks if the value in the given column is available in a dictionary specified for a given condition.

Parameters

ParametersDescription
columnNameColumn value that will be compared with specified criteria.
operatorComparison operator. The allowed values are Equal or NotEqual.
valueDictionary value that will be compared with the value stored in the given column.

Example

Include customers who have T-shirt size number M. The T-shirt sizes are defined in attribute number 1:

Condition 8: Blank

Checks if the specified column has any value set.

Parameters

ParametersDescription
columnNameColumn value that will be compared with specified parameter.
operator- IsBlank - Checks if the column is blank.
- IsNotBlank - Checks if the column is not blank.

Example
Include customers that did not specify city:

Condition 9: CustomerAttribute

Checks the conditions specified for customer attributes. Conditions specified for attribute depend on the data type of given attribute.

Parameters

ParametersDescription
attributeIdUnique identifier of the attribute.
childConditionRequired child condition. The child condition type must be correlated with the attribute type. You can use any of the conditions types here except CustomerAttribute, LoyaltyAccount, Logical, or DictionaryKey.

Example

Include customers who have shoe size number 40.5. Shoe sizes are defined in attribute number 1:

Condition 10: DateComparison

Compares date stored in the specified column with the given value.

Parameters

ParametersDescription
columnNameColumn value that will be compared with specified criteria. It must be a date or datetime data type.
operatorOperator used to perform the comparison. The allowed values are After, Before, Equal, EqualOrAfter, EqualOrBefore, NotEqual.
dateDate in ISO 8601 format that will be compared with the value stored in the column.

Example
Include customers born before 1st of March, 1980, 15:00:

Condition 11: DateIsWithin

Checks if the date occurs within the last or the next number of days from today.

Parameters

ParametersDescription
columnNameColumn value that will be compared with the specified criteria. This column must have a date or datetime data type.
operatorspecified if we compare with past or next days. The allowed values are FutureDays, PastDays.
numberOfDaysNumber of days within which the date must take place either in past or in the future, depending on the value of the operator parameter.

Example
Include customers that registered today or in the past 30 days:

Condition 12: DecimalComparison

Compares value stored in the column with the given value.

Parameters

ParametersDescription
columnNameColumn to compare the value with comparedValue.
operatorOperator used for comparison. The allowed values are Equal, Greater, GreaterOrEqual, Less, LessOrEqual, NotEqual.
comparedValueValue compared against the column.

Example
Include customers with at least 10,000 loyalty points:

Condition 13: DictionaryKey

Checks if the value in the given column is equal or different than the specified dictionary key.

Parameters

ParametersDescription
columnNamevalue that will be compared with specified criteria.
operatorComparison operator. The allowed values are Equal or NotEqual.
keyValueDictionary key value that will be compared with the value stored in the given column.

Example
Include customers from Poland (key 137):

Condition 14: IntegerComparison

Compares value stored in the column with the given value with precision to integers.

Parameters

ParametersDescription
columnNameColumn to compare the value with comparedValue.
operatorOperator used for comparison. The allowed values are Equal, Greater, GreaterOrEqual, Less, LessOrEqual, NotEqual.
comparedValueValue compared against the column.

Example
So far IntegerComparision is used only for CustomerAttributes. For example, include customers with at least 10000 points of attribute number 1:

Condition 15: Logical

Allows combining several conditions using the given logical operator.

Parameters

ParametersDescription
operatorLogical operator used to combine child conditions. The allowed values are And or Or.
childConditionsArray of conditions to be combined using the selected operator.

Example
Include customers that either live in Katowice or did not specify any city:

Condition 16: LoyaltyAccount

Checks if the customer has an account in the given loyalty program and earning type and allows to specify additional conditions related to loyalty account columns.

Parameters

ParametersDescription
loyaltyProgramKeyKey of the loyalty program.
earningTypeKeyKey of the earning type for the account.
childConditionOptional child condition. You can use any of the conditions types here except LoyaltyAccount because they cannot be nested. Only columns from the LoyaltyAccount table can be used in conditions.

Example 1
Include customers who have an account with earningTypeKey=14 and loyaltyProgramKey=11:

Example 2
Include customers which have more than 10,000 points on a given account:

Condition 17: TextComparison

Compares text column value with the given string.

Parameters

ParametersDescription
columnNameColumn value that will be compared with specified criteria.
operatorOperator used for comparison. The allowed values are Equal, NotEqual, StartsWith.
textText to be compared with the value in the column.

Example
Include all customers who live in the city whose names begin with "Kat":

Condition 18: Transaction (Txn.Empty or Txn.Logical)

Indicates customers who performed transactions with given conditions.
The Txn.Empty handles a single query while Txn.Logical handles multiple queries connected with the joining operator.