Table of Contents:

What is an Expression Mapping?


The "Expression" data binding option allows to map each Answer Option to more complex rules. These rules allow mapping an Answer Option to expressions containing values of different product attributes. Thus, expression mapping is the most powerful of the three Types of Answer Option Data Binding.

Since the binding of Answer Options to data attributes can differ for each Answer Option, the configuration dialog for the attribute binding is placed in the Answer Option properties dialog and not in the Question (compare to Single Attribute Connection in Answer Option).

When is the Expression Mapping Recommended?


  1. Whenever you need a more complex logic with AND (conjunction) or OR (disjunction) statements.
  2. Whenever you want to connect one Answer Options to several data attributes.
  3. If you want to use mathematical comparison operators, like less or greater, in connection with attributes of type number.
    • e.g. for the price attribute

Expression Structure


  • Attribute: You can choose any product attribute from the uploaded product data file. This also gives you the flexibility to build expressions for one Answer Option across a variety of product attributes.

  • Cond. ("condition"): Set the mathematical operator that compares the Attribute with the selected Value.
    • For data attributes of the type "Text" or "Boolean" you can choose between the "=" (equal), "≠" (unequal) operators, "" (contains), "" not contains and "*" (regular expression) .
    • For attributes with type "Number" you may also select the operator "<" (less), "<=" (less equal), ">" (greater) or ">=" (greater equal).
    • All possible mathematical operators are: =, ≠, <, <=, >, >=

  • Value: Represents one data attribute value from the selected product attribute. 
    • It is also possible to enter values, which are not part of the value set. These are called unbound values. Depending on the selected condition operator, they are displayed in different colors with different meanings (see Meaning of the different value colors).

  • Logical operator: You can select  "AND" (conjunction) and "OR" (disjunction) operators between two expression rows.
    • "AND" means that both expressions have to be true at the same time for a product to match. The example in Connect a Single Attribute to an Answer Option will be interpreted as: a product should cost between 500 and 1000.
    • "OR" means that at least one of the two expressions has to be true to match with a product.

Example and its Configuration steps


Example Question

It is assumed that you want to ask a Question about the price range a user is willing to spend. Every Answer Option represents a certain price range.


These price ranges can easily be expressed with mathematical operators. Therefore change the "Answer Option Data Binding" to the type "Expression" in the "Data Binding and Connections" tab (see image below).

Product Data File

Furthermore your uploaded product data file contains the product attributes "price", "hdmi_port" and "display_resolution" which are used in this example.

Attribute Description

  • id: unique product identifier
  • name: product name
  • price: product price
  • hdmi_port: Boolean value which signals whether the product contains HDMI connectors.
  • display_resolution: Describes how good is the resolution of the TV screen.


Info

Make sure that the attribute "price" has the type number (see Upload your Product Data - Data Attributes Table).

Connect a Single Attribute to an Answer Option

Afterwards you can enter expressions for each Answer Option of this Question. The goal is to build a price range from 500 to 1000 € which represents the medium budget range.

The following steps describe how to configure this range:

  1. Click on the Answer Option label, e.g. on "medium budget". The Answer Option properties dialog shows up.
  2. Go to the "Data Binding and Connections" tab.
  3. Select the attribute "price" in the combobox "Attribute".
  4. Choose the mathematical operator ">=" (greater than or equals) in the combobox "Cond.".
    ("Cond." stands for "condition")
  5. Afterwards select or type the value "500" in the combobox "Value".
  6. Furthermore add another expression. Click on the button "Add Expression". This creates another expression row. Additionally, a logical operator between the two expression rows is added.
  7. Make sure that the logical operator combobox is set to "AND".
  8. In the new expression row select the attribute "price" again.
  9. Choose the mathematical operator "<=" (less than or equals).
  10. Select the value "1000".

After these steps, the desired price range is set for the Answer Option "medium budget".


Info

Each expression row can be deleted by clicking on the "X" button on the right side of each row.

Connect Multiple Attributes to an Answer Option

The following example shows a more complex case of binding your Answer Options to multiple product data attributes.

It is assumed that you want to ask the user for what he wants to use his TV. Most of the times, different use cases require dependencies to several data attributes.

Assume a case where the user wants to buy a TV for gaming:

In this example, you connect the Answer Option "use the TV for video games..." with the two attributes "hdmi_port" and "display_resolution" (see Attribute Description). You want to achieve that the TV has at least one HDMI port for the console and Full-HD resolution for a good gaming experience. That is why you select the values "yes" for "hdmi_port" and "full_hd" for "display_resolution". Moreover make sure that the logical operator is set to "AND".

Meaning of the Different Value Colors

ColorMeaning

Grey

The value is part of the current attribute value set (bound value).
Yellow

The value is currently not part if the attribute value set (unbound value).

Perhaps, it is an old value from an earlier data feed. Or a numeric value which although is not represented in the product data, can be used as a boundary for less or greater operators.

GreenThis color suggest, that the entered value is a subset of existing values. So all values are bound which contain () or not contain () this text.
PurpleIf the regular expressions operator is selected, the color changes to purple. Now, the value is interpreted as patterns to find more complex value connections. To use these patterns correctly, please look at this documentation.

How to Configure More Than One Logical Operator?


There are three different kinds of configurations:

  • Only conjunctions:
    e.g. "Price <= 999 AND Price >= 499 AND ..."

  • Only disjunctions:
    e.g. "Gender = female OR Gender = unisex OR ..."

  • Mix of "AND" and "OR" in one expression: 
    e.g. "Price <= 999 AND Price >= 499 OR Gender = female"


Info

All conjunctions bind stronger than disjunctions. That means that brackets are set implicit. In the last example above, the bracket would be set as follows: "( Price <= 999 AND Price >= 499 ) OR Gender = female"


Read on about Automatic Mapping


  • No labels