Learn how to set different conditional cases and a default case for value components.
This article describes how to set conditional values. Its configuration and settings available are also covered.
Note: Conditional values are not to be confused with (general) conditions which are set at the output value level only. Learn more about their difference here.
Using conditional values
Selecting the Condition option when building the output value lets you decide in which cases a certain value component should apply and also set a default unconditional value.
To add a conditional value, click on `Add output value´ or `Add value´ > `Condition´
Its configuration consists in defining (1) one or more cases and (2) a default case.
Settings:
- Case(s) - Condition module
- Default (unconditional) case
You can think of it as an IF-Then (ELSE) function.
Example
In this example, we'll build an output for campaign names that includes a conditional value.
Let's say that based on your company naming conventions, you want to build a name that:
- starts with the company abbreviation. E.g., ABC
- contains data about year, market, funnel stage, campaign name, and network
- uses underscore (_) to separate values
However, for campaigns created before 2022, the input data to retrieve should be `Country´ instead of `Market´. The structure stays the same but one value component changes depending on different cases.
This is a conditional value since the condition is applied to a value component that is part of the output value. It does not define the case when a certain output value should apply (general conditions).
Hence:
- ABC is a static value since it does not change
- year, funnel stage, campaign name, and network are single input fields
- there is a conditional value - IF the year is 2021 (logical test) THEN return market (case1) ELSE return country (default), where market and country are single input fields
The final output would look something like:
ABC_21_DK_awareness_SummerPromo_Amazon (case 1)
ABC_22_Nord_awareness_SummerPromo_Amazon (default case)
Detailed breakdown (click here)
Output field type: Text
Output value: Combined value
Join
Value components:
- Static value > ABC
- Input field > Year
- Conditional case > IF Year is 2021 THEN return Country (case1). ELSE return Market (default)
- Input field > Funnel Stage
- Input field > Campaign name
- Input field > Network
Rules: none
(General) Conditions: none
Formatted as a formula string
JOIN(delimiter; static value1; value2; conditional value3; value4; value5; value6)
JOIN(_; ABC; year; IF(year=2021; return country, else market); funnel stage; campaign name; network)
Condition module
You can set conditional cases by setting the condition module:
- Choose the scope of the condition
Define whether ALL the conditions have to be present, or if just ANY condition is sufficient.
- Select the parameter to be evaluated
Click `Add expression´ > `Input fields´ > Select the parameter to be evaluated
- Define the comparison expression
Select the comparison operator and value
Note: A condition module is a Boolean that evaluates a comparison/logical expression and returns a result. If the result of the expression is true, the first-case match applies and if the result is false, the following case is considered.
Condition groups
You can build conditions that contain multiple sub-conditions and combine them into groups.
To create a group:
- Create an expression
- Click on it > Click on the group icon
- `Add expression´ within the group
You can keep creating groups and nesting them within other groups.
Also, each group can be evaluated with its own ANY or ALL logic. This lets you define a condition that uses different scopes.
Default value
Setting a default value means that an unconditional value is returned if none of the previous cases apply (no conditions are met). If you do not set any default value, you risk returning an empty string.
To set the default value, simply click `Add a default value´ > Define a value
Tip: Theoretically, you could use both Conditional values and general Conditions to build the same cases. However, there are differences that need to be considered. Learn more here.