Skip to main content

Create texts depending on the values with the IF function

It often happens that we need a different behavior depending on a value, e.g. for the structure of texts. This is the case, for example, when we use elements in our text function that are not the same for all product types (e.g. simple and configurable products). Here the IF function can be a solution.

IF function

The IF function checks an expression (a comparison) and works one way if the comparison matches, or another way if the comparison is false. This is also how the three parameters of the function are explained: Check, Then_Value, and Other_Value.

It is important to note that the first parameter Check must always return a result in the form of TRUE or FALSE (Boolean value). To compare different values with each other, there are the operators = (both values are identical), > (the first value is greater than), < (the first value is less than) and < > (both values are not equal).

Here are a few examples of tests and their results:

  • 1=1 – TRUE
  • 1=0 – FALSE
  • “Dog”=”Cat” – FALSE
  • “Dog” < > ”Cat” – TRUE
  • 1 > 0 – TRUE
  • 1 > 2 – FALSE


In our example, we want to include an attribute used to create configurable products in the meta title. Since this attribute is always empty for the configurable products, we use the IF function to build the text properly.

Building on the CONCATENATE example, we add a new column next to the meta title. We select the first cell of the new column and switch to the formula bar. There we enter the call for the IF function. The result of the check should be TRUE if it is a simple product. The type of product in the current row is indicated in the Type column. The check compares the column Type with the text constant "simple", which stands for simple products. To do this, we first select the Type column and then enter the equal sign ( = ) followed by "simple".

By entering a semicolon ( ; ) we specify the then_value. Since this is a text, we also use double quotes ( " ), in our example " size ". The Other_Value must be specified and consists here only of two double quotes "".

Finally, our new column is added to the CONCATENATE function:

=IF([@Type]=”simple”;”Größe “;””)