Functions for rules and optimisations

How to access to the functions list from the interface? When creating a rule or optimisation or in an attribute's tooltip > "Need function?" link

Note: Dollar signs "$" always frame an attribute name. Being a semi-automatic entry, the second dollar sign is automatically added after the attribute name in the function.

1. Text functions

  • UPPER: Turn all the characters into capitals

Syntax: UPPER($text_field)

Example: I want all the characters sent to the attribute "title" to be in capital letters.
I enter: UPPER($name$)

  • LOWER: Turn all the characters into lower-case

Syntax: LOWER($text_field)

Example: I want all the characters sent to the attribute "title" to be in lower-case.
I enter: LOWER($name$)

function-lower2.png

  • UPPERWORD: Capitalizes the first letter in a text string and any other letters in text that follow any character other than a letter

Syntax: UPPERWORD($text_field)

Example: I want the first letter of each word to be a capital, in the attribute "title".
I enter: UPPERWORD($name$)

function-upperword2.png

  • UPPERSENTENCE: Capitalizes the first letter of each sentence

Syntax: UPPERSENTENCE($text_field)

Example: I want each sentence to begin with a capital, in the attribute "description".
I enter: UPPERSENTENCE($description$)

function-uppersentence2.png

  • TRUNC: Limit the number of characters

Syntax: TRUNC($text_field,number of characters)

Example: I want to limit my description to 2,000 characters.
I enter: TRUNC($description$,2000)

function-trunc.png

  • SMARTTRUNC: Limit the number of characters without cutting off the last word

Syntax: SMARTTRUNC($text_field,number of characters)

Example: I want to limit my description to 2,000 characters without cutting off the last word.
I enter: SMARTTRUNC($description$,2000)

function-smarttrunc.png

  • TAIL: Retrieve the last characters of a text string according to the number of characters you specify

Syntax: TAIL($text_field,number of characters)

This function is useful to isolate the last characters of a string and use them as value in my catalogue.

Example: I want to get the last 4 characters of my product type.
I enter: TAIL($product_type$,4)

function_TAIL.png

  • SPLIT : Divide the content of the values around a character

Syntaxe : SPLIT($text_field,separator, field number)

This function is useful to isolate a part of the text of a string starting from the left of the string in order to isolate this part of text and use it as a value in my catalogue.

Exemple : In the "product_type" attribute, I want to isolate a value from Plug&Play.
The value contained in the "product_type" field of my catalogue is "Plug&Play". The values are therefore seperated by the character "&".

  • to retrieve only "Plug" (1st value of the chain), I enter: SPLIT($product_type$,&,1)

SPLIT_1.png

  • to retrieve only "Play" (2nd value of the chain), I enter: SPLIT($product_type$,&,2)

SPLIT_2.png

Use quotation mark when using the pipe character as separator.
ex: SPLIT($product_type$,"|",1)

  • STRIPHTML: Remove the HTML tag

Syntax: STRIPHTML($html_text_field)

Example: I want to remove the html tags from my description.
I enter: STRIPHTML($description$)

striphtml.png

  • DECODEHTML: Decodes special characters from HTML elements.

Syntax: DECODEHTML($html_text_field)

Example: The brands in my catalogue are encoded in HTML (ex: "Pull & Bear") and I want to decode them (ex: "Pull & Bear").
I enter: DECODEHTML($brand$)

decodehtml.png

  • URLENCODE: Encode the values to send in a URL

Syntax: URLENCODE($text_field)

Example: I want to add the title of my products in the tracking of my URL products.
I enter: $url$?URLENCODE($name$)

function-urlencode2.png

  • CATEGORYLEVEL

This function is useful if you have a breadcrumb categorization, i.e. if you have several levels of categories in the same line.

Ex : Home > Fashion > Shoes > Nike shoes

The function then allows you to select a level and extract it to use it as a final category with your channel in Lengow.

2020-03-03_15h33_30.png

Syntax : CATEGORYLEVEL(2)

With this syntax we get the second value of my category, "Fashion" thanks to the function.

Other syntax : CATEGORYLEVEL(-1)

Here I retrieve the last level of categorization, i.e. "Nike shoes" thanks to the value "-1" called in the function.

Other syntax : CATEGORYLEVEL(-2)

Allows me to retrieve the penultimate level, i.e. "Shoes".

Note: There is no need to "call" the catalogue category using the $ symbol because Lengow automatically retrieves the values of the category mapped at the Initial product attributes mapping step.

2. Mathematical functions

  • ROUND: Round a number up/down and define the number of decimals

Syntax: ROUND(number to round up/down,number of figures desired after the decimal point)

Round up/down the number, to the nearest tenth, hundredth...of a decimal number, cutting down to the stated rank then:

  • if the following number is 5, 6, 7, 8 or 9, you increase the last figure of the cut number by 1.
  • if the following number is 0, 1, 2, 3 or 4, you keep the cut number.

To round up to a whole number, mark "0" as "the number of figures desired after the decimal point" or mark ROUND(numbertoround).

Example:

  • To round a price to two figures after the decimal point: ROUND($field_price,2) > If my price is "14.1576" in my catalogue, it becomes "14.16".
    Ex: ROUND($price$,2)

function-round.png

  • To remove decimals of quantity values: ROUND($field_quantity,0) or ROUND($field_quantity) > If my quantity is "4.000" in my catalogue, it becomes "4".
    Ex: ROUND($price$)

function-round-sansparametre.png

  • ROUNDUP: To round up to the nearest whole number

Syntax: ROUNDUP(number to round up to the nearest whole number)

Example: I want to round my price up to the nearest whole number.
I enter: ROUNDUP($price$)

function-roundup.png

  • ROUNDDOWN: To round down to the nearest whole number:

Syntax: ROUNDDOWN(number to round down to the nearest whole number)

Example: I want to round my price down to the nearest whole number.
I enter: ROUNDDOWN($price$)

function-rounddown.png

  • FORMAT_NUM: Display a price in a format that you can manage to the decimal digit of your choice 

Syntaxe : FORMAT_NUM($price$,decimal digit wanted,"separator wanted")

  • Decimal separator accepted: a point or a comma

Exemple : I want to display a price with two decimal digits.
I enter: FORMAT_NUM($price$,2,",")

Fonction_Format_NUM.png

You can couple this function with the other mathematical functions.

To do so, check the step "Concatenate several functions". 

The function "ROUND" rounds a price by allowing you to choose the precision, but does not allow you to keep the "0" to have a fixed number of digits after the decimal separator.
FORMAT_NUM allows you the display of this "0".
  • CALC: Perform a calculation

  • Divide: CALC(number1/number2)
  • Multiply: CALC(number1*number2)
  • Addition: CALC(number1+number2)
  • Subtraction: CALC(number1-number2)

"number1" and "number2" can be replaced by "$my_field"

With the assistance of brackets, any calculation can be performed. The function performs the calculations in order of priority.

Example: I want to calculate the reduction percentage of my reduced products.
I enter: CALC((($price$-$price_promo$)*100))/$price$

function-calc1.png

I want to increase my sales price by 10%, round it up to the nearest whole number, and subtract 10 cents.
I enter: CALC(ROUNDUP($price$*1.1)-0.1)

function-calc4.png

I want to reduce my sales price by 15% and add my shipping costs increased by 5%.
I enter: CALC(($price$*0.85)+($fdp$*1.05))

function-calc3.png

  • CURRENCYCONV: Convert a price in another currency

Syntax: CURRENCYCONV(price,iso_code)

Example: I want to convert a price into GBP.
I enter: CURRENCYCONV($price$,GBP)

function-currencyconv.png

Conversion rates are based on the European Central Bank (ECB) and are updated once a day.

3. Concatenate several functions

Combine as many functions as you like whilst playing with the brackets!

Example: I want to increase my sale price by 10% and round the result by two figures after the decimal point.
I enter: ROUND(CALC($prix_ttc$*1.1),2)

Example: I want to limit my description to 2,000 characters and write the text in capitals.
I enter: UPPER(TRUNC($description$,2000)

function-truncupper.png

Example: I want to increase my sales price by 10% and convert it into euros.
I enter: CURRENCYCONV(CALC($price$*1.1),EUR)

function-currencyconvcalc.png

Example: The text of my descriptions is in upper-case letters. I want the first letter of each phrase to be an capital letter, whereas all the other letters will be lowercase letters.
I enter: UPPERSENTENCE(LOWER($description$))

capture-decran-2017-07-27-a-105135.png

Example: I want to round to two digits after the comma, the percentage of the product promotion, calculated from the stricked through price and reduced price from my catalogue.
I enter: ROUND(CALC((($full_price$-$prix_promo$)*100)/$full_price$),2)

rule2.png

In this example "Full_price" is the field which contains the price before the promotion and "Prix_Promo" is the field which contains the reduced price (product price during the promotion).

Example: I want to round down the price plus 20% and add the decimal .99 to apply a psychological price.
I enter: ROUNDDOWN(CALC($price$*1.20)).99

2020-04-16_17h27_03.png

In this example, "price" is the catalogue field which contains the product selling price.

-

Articles in this section

Access help center for our Market Intelligence solutions
NetRivals & NetMonitor