Friday, March 29, 2024
No menu items!
HomeData IntegrationHow to Handle Nulls in Formulas | Best Practices

How to Handle Nulls in Formulas | Best Practices

Read Time: 4 minutes

When automating a business process, whether it’s building a data pipeline or creating a bots-based workflow, more often than not it requires applying formulas to transform data. 

Formulas in Workato are pre-built functions that let you convert data types, remove unnecessary characters, check for correctness of data, change cases, split strings, format dates, and much more. There are over 400 unique formulas that you can either use independently or in combinations by chaining them together with dots, as shown here:

Working with NULL values

Formulas, while incredibly useful, do need special handling when operating on null values. Just like any other function, they expect valid input values in order to produce a desired output.

Formulas are expected to report errors when input data pills contain the occasional null value. Null values in data pills can be an outcome of an incorrect data-mapping step, or just the source data field missing some information.

These formula errors have the potential to cause the recipe to stop entirely, making it even more important to handle nulls immediately. 

How to nullify the NULL challenge

Here are 3 simple and effective ways you can handle nulls and avoid formula errors to keep your automations running smoothly.

Using Prefixes: You can add the “&.” operator before each formula to indicate that the formula should be applied only when the input value is not null. In the event you are chaining multiple formula functions, the “&” operator must be used for each formula in the chain.                                                                                                                                                                                                                   
Using Alternate Values:                 It is common for applications to store the same or similar information in multiple fields. For example, the contact email of a lead may be stored in a “work email” field or a “personal email” field in your CRM app; the address information can be in the shipping or billing address fields; contact’s work phone or mobile phone.  Let’s look at a case where we need to capture a lead’s email. The source application may always contain a value in one of the two fields or in both fields. Because we care to get a valid email address for the lead, we can construct a formula to choose the work email when present, or alternatively choose the personal email when work email has no value i.e. NULL. It is important to know that the order of the fields specified in the formula determines which value will be selected first i.e. in this case work email will be prioritized over personal email.                                                                                                                                                 
Using Conditional Statements: In some situations there could be a requirement to be very precise in selecting the right value for the formula. By using conditional logic in formulas, which looks like an if-else statement you can express advanced conditions for selecting the right value.The condition at the beginning is just a boolean expression that evaluates to true or false, and the outcome decides which expression is returned. If the condition is true, the formula returns expression 1, and if the condition is false, it returns expression 2. Using the example of capturing a lead’s email, we could create a formula that uses the work email when the lead type is an organization and a personal email when it is just an individual. That formula would look like this:

Null values are an inescapable reality when it comes to working with data. Being able to handle nulls the right way is extremely important for both the health of automations and data quality requirements of business processes. Visit the docs page on Formulas to learn more.

The post How to Handle Nulls in Formulas | Best Practices appeared first on Workato Product Hub.

Read MoreWorkato Product Hub

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments