Formula: Convert Lastname, Firstname to Firstname Lastname

Thomas_937381
Thomas_937381 Posts: 196
edited July 2020 in Show and Tell

Using the below formula in a Fields: Field formulas action will convert Lastname, Firstname to Firstname Lastname. This can be useful in document assembly and data processing-type patterns.

result = fields['name'].split(", ").reverse().toString().replace(","," ")

The same formula can be used in CSV: Apply formulas to columns or Tables: Apply formulas to columns:

columns['Name'] = columns['Name'].split(", ").reverse().toString().replace(","," ")

Comments

  • Alternately, this formula will change Firstname Lastname to Lastname, Firstname. Note that it assumes the name contains a single whitespace; names also containing middle names, middle initials, and multiple surnames may require additional work of the formula.

    result = fields['name'].split(" ").reverse().toString().replace(",",", ")

    The same formula can be used in CSV: Apply formulas to column_s or _Tables: Apply formulas to columns:

    columns['Name'] = columns['Name'].split(" ").reverse().toString().replace(",",", ")