Use the if/then/else block to establish a sequence of if/else/then provisions to generate a property based on diverse criteria.
When you provide an input record, the first matched if provision generates the output. If none of the if provisions meet the conditions for a given input record, and you specify an else value, it is used. If no else value is specified, the output is null.
The if/then/else block consists of a sequence of if/then definitions, with at least one required, followed by an optional else block.
To add an if/then condition, click + > Add Condition.
Configure the block with the following fields:
- If condition – Acts as a filter on source data, which may include properties of a dataset, such as a column, derived column, or block. Configure one or more filter conditions grouped into a hierarchy of nested and/or conditions with arbitrary depth. Use the following comparison operators (string comparisons are case-insensitive):
-
- is – Checks if the left side equals the right side.
- is not – Checks if the left side does not equal the right.
- contains – Determines if the left side string contains the right side as a substring.
- in – Verifies if the left side is present within the set of values on the right side.
- <, >, >=, ... – Applies mathematical operators.
-
- Then – Assigns the output value for data that matches the corresponding if condition. This value may include a constant value, a dataset column or derived column property, another block, or a parameter.
- Else – If none of the if conditions match the source data, the default value to output is the else value. This value can be constant, a property like a dataset column or derived column, another block, or a parameter.
Example
To group values using if/then/else,
- Create a new exploration or open an existing one. As an example, choose a funnel.
- Select a measure and configure the different stages for your funnel.
- Open the block panel on the left.
- Click + to add a new block and choose the If/Then/Else block to categorize users who have 4k enabled. In the If block, select 4k_enabled from the drop-down list, set True as the value, and in the Then field, add a string that says 4k enabled. In the Else block, add a string that says 4k not enabled.
- Click Apply.
- Select the block you created, in the Group by Property section, and run the exploration to see the grouped results.
- Click Save.
Output
The output of an if/then/else block is determined by the results of the then and else portions specified within the definition.
Please sign in to leave a comment.