This article will walk you through some of the most common formula use cases and how to solve for them.
Workflow Designer formulas enable you to build complex logic calculations directly into your workflow configurations. This reduces manual data entry in launch forms and gives legal teams confidence that the data in their contracts is calculated correctly.
Formulas are a powerful way to automate complex calculations that live within your templates, however, they can increase the complexity of your workflow building process. Formulas are built with a few guidelines to ensure you do not have any unexpected outcomes in your workflows.
To learn more about how to use formulas, refer to Manage Formulas.
For a walkthrough of example formulas and more information on supported Formula types, refer to the Formulas Help Center.
Use a Value if a Particular Property Exists
IfExists([My Property], [whatever should return if My Property exists])
IfExists([My Property], [My Property])
IfExists([Property A], [Property B], Add([Property A], [Property B]))
- This is an unsafe formula! It will throw an error and break the workflow if Value 2 does not exist:
Add([Value 1], IfExists([Value 2], [Value 2]))
- This is the safe version, which handles the scenario in which Value 2 does not exist:
Add([Value 1], IfEmpty(IfExists([Value 2], [Value 2]), 0)
Display a Checkbox
If([Testing Checkbox], "☒", "☐")
Extract the Year from a Date
FormatDate([Your Date Property], "yyyy") // returns "2023"
FormatDate([Your Date Property], "yy") // returns "23"
Extract the Month from a Date
FormatDate([Your Date Property], "M") // returns a Text value like "2"
FormatDate([Your Date Property], "MM") // returns a zero-padded Text value like "02"
FormatDate([Your Date Property], "MMM") // returns a Text value like "Feb"
FormatDate([Your Date Property], "MMMM") // returns a Text value like "February"
TextToNumber(FormatDate([Your Date Property], "M"))
Extract the Day of the Month from a Date
FormatDate([Your Date Property], "d") // returns a Text value like "2"
FormatDate([Your Date Property], "dd") // returns a zero-padded Text value like "02"
TextToNumber(FormatDate([Your Date Property], "d"))
Extract the Day of the Week from a Date
FormatDate([Your Date Property], "eee") // returns an abbreviated Text value like "Tue"
FormatDate([Your Date Property], "eeee") // returns a Text value like "Tuesday"
Populate the Last Day of the Month
RelativeDate(RelativeDate(StartOf([My Date], "month"), 1, "month"), -1, "day")
Format a Date as YYYY-MM (e.g., “2023-04”)
FormatDate([Your Date Property], "yyyy-MM")
Format a Date as YYYY-MM-DD (a/k/a “ISO Format,” e.g., “2023-04-15”)
FormatDate([Your Date Property], "yyyy-MM-dd")
State Abbreviation Based on State Name (e.g., “CA” from “California”)
Switch(State([Your Address Property]),
"Alabama", "AL",
"Alaska", "AK",
"Arizona", "AZ",
"Arkansas", "AR",
"American Samoa", "AS",
"California", "CA",
"Colorado", "CO",
"Connecticut", "CT",
"D.C.", "DC",
"Delaware", "DE",
"District of Columbia", "DC",
"Florida", "FL",
"Georgia", "GA",
"Guam", "GU",
"Hawaii", "HI",
"Idaho", "ID",
"Illinois", "IL",
"Indiana", "IN",
"Iowa", "IA",
"Kansas", "KS",
"Kentucky", "KY",
"Louisiana", "LA",
"Maine", "ME",
"Maryland", "MD",
"Massachusetts", "MA",
"Michigan", "MI",
"Minnesota", "MN",
"Mississippi", "MS",
"Missouri", "MO",
"Montana", "MT",
"Nebraska", "NE",
"Nevada", "NV",
"New Hampshire", "NH",
"New Jersey", "NJ",
"New Mexico", "NM",
"New York", "NY",
"North Carolina", "NC",
"North Dakota", "ND",
"Northern Mariana Islands", "MP",
"Ohio", "OH",
"Oklahoma", "OK",
"Oregon", "OR",
"Pennsylvania", "PA",
"Puerto Rico", "PR",
"Rhode Island", "RI",
"South Carolina", "SC",
"South Dakota", "SD",
"Tennessee", "TN",
"Texas", "TX",
"Trust Territories", "TT",
"Utah", "UT",
"Vermont", "VT",
"Virginia", "VA",
"Virgin Islands", "VI",
"Washington", "WA",
"West Virginia", "WV",
"Wisconsin", "WI",
"Wyoming", "WY",
"ERROR"
)
Get the Correct Indefinite Article Based on State Name
Switch([Your State Property],
"Alaska", "an",
"Alabama", "an",
"Arkansas", "an",
"American Samoa", "an",
"Arizona", "an",
"Iowa", "an",
"Idaho", "an",
"Illinois", "an",
"Indiana", "an",
"Ohio", "an",
"Oklahoma", "an",
"Oregon", "an",
"Utah", "an",
"a"
)
Displaying Cents from a Monetary Amount
(
MonetaryValue([Your Monetary Amount Property]) -
Truncate(MonetaryValue([Your Monetary Amount Property]))
) * 100
Date Examples for Termination Dates
Termination Date (365 Days): RelativeDate([Agreement Date], 365, "days")
Termination Date (12 Months): RelativeDate([Agreement Date], 12, "months")
Termination Date (1 Year): RelativeDate([Agreement Date], 1, "years")
Termination Date (1 Year minus 1 Day): RelativeDate(RelativeDate([Agreement Date], 1, "years"), -1, "days")
Termination Date (1.5 Years): RelativeDate([Agreement Date], 18, "months")
Unique Values per Dropdown Item
Switch([Legal Entity],
'Ironclad, Inc.','US Address Here',
'Ironclad, Ltd.','UK Address Here',
'Fall Back Address Here'
)
If A then... Else If B then... Else...
If([BooleanValueA],
"Value if A is true",
If(
IfEmpty(IfExists(TheBooleanProperty, TheBooleanProperty), false),
"Value if B exists and is true",
"Fallback value"
)
)
Table-Like Lookups
Switch( Concat( IfEmpty(IfExists([Property 1], [Property 1]), "Empty"), "~", IfEmpty(IfExists([Property 2], [Property 2]), "Empty"), ... ), "Value 1 for Property 1~Value 1 for Property 2", "Result for this combo", "Value 1 for Property 1~Empty", "Result for this other combo", ..., "Some fallback value here if nothing matched" )
Switch( Concat( IfEmpty(IfExists([Primary], [Primary]), "Empty"), "~", IfEmpty(IfExists([Secondary], [Secondary]), "Empty") ), "Apple~Empty", 1, "Apple~Banana", 2, "Apple~Pear", 3, "Banana~Pear", 4, "Banana~Peach", 5, "Pear~Grape", 6, "Pear~Empty", 7, "Pear~Peach", 8, 99 )
="""" & IF(A2 = "", "Empty", A2) & "~" & IF(B2 = "", "Empty", B2) & """, " & C2 & ","
Dates in French Text
Concat(
FormatDate([Your Date Property], "d"),
If(Equals(FormatDate([Your Date Property], "d"), "1"), "er", ""),
" ",
Switch(FormatDate([Your Date Property], "M"),
"1", "janvier",
"2", "février",
"3", "mars",
"4", "avril",
"5", "mai",
"6", "juin",
"7", "juillet",
"8", "août",
"9", "septembre",
"10", "octobre",
"11", "novembre",
"12", "décembre",
"ERREUR"
),
" ",
FormatDate([Your Date Property], "yyyy")
)
Dates in Spanish Text
Concat(
FormatDate([Your Date Property], "d"),
If(FormatDate([Your Date Property], "d"),
" de ",
Switch(FormatDate([Your Date Property], "M"),
"1", "enero",
"2", "febrero",
"3", "marzo",
"4", "abril",
"5", "mayo",
"6", "junio",
"7", "julio",
"8", "agosto",
"9", "septiembre",
"10", "octubre",
"11", "noviembre",
"12", "diciembre",
"ERROR"
),
" de ",
Switch(FormatDate([Your Date Property], "yyyy")
)
French Numbers in Text Form
IfExists([Your Number Property],
Switch([Your Number Property],
1, "un",
2, "deux",
3, "trois",
4, "quatre",
5, "cinq",
6, "six",
7, "sept",
8, "huit",
9, "neuf",
10, "dix",
11, "onze",
12, "douze",
15, "quinze",
18, "dix-huit",
20, "vingt",
24, "vingt-quatre",
25, "vingt-cinq",
30, "trente",
36, "trente-six",
40, "quarante",
45, "quarante-cinq",
48, "quarante-huit",
50, "cinquante",
60, "soixante",
70, "soixante-dix",
75, "soixante-quinze",
80, "quatre-vingts",
90, "quatre-vingt-dix",
100, "cent",
120, "cent vingt",
"VEUILLEZ MODIFIER CE TEXTE"
)
)
Spanish Numbers in Text Form
IfExists([Your Number Property], Switch([Your Number Property], 1, "uno", 2, "dos", 3, "tres", 4, "cuatro", 5, "cinco", 6, "seis", 7, "siete", 8, "ocho", 9, "nueve", 10, "diez", 11, "once", 12, "doce", 15, "quince", 18, "dieciocho", 20, "veinte", 24, "veinticuatro", 25, "veinticinco", 30, "treinta", 36, "treinta y seis", 40, "cuarenta", 45, "cuarenta y cinco", 48, "cuarenta y ocho", 50, "cincuenta", 60, "sesenta", 70, "setenta", 80, "ochenta", 90, "noventa", 100, "cien", 120, "ciento veinte", "POR FAVOR EDITE ESTE TEXTO" ) )