Calculated Field – Concatenating Text

    Overview

    This article will walk through how to use the concat() function in a Sugar® Logic formula to combine any number of strings separated by commas into a single string. Specifically, we will combine the first name and last name fields of a module. This process is called concatenation.

    For more information on Sugar Logic and Calculated Fields, please refer to the Introduction to Calculated Fields article.

    Use Case

    In this example, we will combine the first name and last name fields of a module. Currently, the first name field contains “Jane” while the last name field contains”Doe”.

    Prerequisites

    You will first need to create a new field of type TextField and mark it as calculated before entering the formula below.

    Formula

    concat($first_name, " ", $last_name)

    The result in our example will be a textfield reading “Jane Doe”.

    If you would like to include other text that is not being pulled from a separate field, you can add strings within quotes to the formula. For example, if we wanted the final field to read “Jane Doe is the CEO of her company”, we would use the first and last name fields from the formula above as well as the Title field which contains “CEO”.

    concat($first_name, " ", $last_name, " is the ",$title, " of her company.")

    Formula Breakdown

    The concat() function will combine any number of strings separated by commas into a single string. This process is called concatenation.

    Everything within a set of double quotes will be added to the field as a literal string (including spaces) rather than a variable. If your final text is missing an expected space between words, you can add a set of double quotes with a space in the middle to that part of the formula, divided from the other parts by commas.

    in Sugar Logic

    Reach out to us for help