Comparing text strings using IF statements
  • 04 Oct 2022
  • 1 Minute to read
  • Dark

Comparing text strings using IF statements

  • Dark

Article Summary

The IF function will return one of two values depending on whether a logical argument is true or not. This article will cover how to compare a string of text against a logical argument using an IF statement.

IF statements (or conditional statements) are written in the following format:

IF([logical argument], [value1],  [value2]) 

This function means "If [logical argument is true], then return [value1]. Otherwise, return [value2]." The logical argument can either be text or a numeric value, e.g. {Pet's Name}='Rufus' or {Test Score}>75. The return value options can be text, numeric values, or use field names.

Using a single IF statement

As an example, let's say that you want to track a few projects that are in progress, and output a different message based on the status of the project. Each project can have a status of Not started, In Progress, or Complete.

Here's what you may want to output in another field based on the status:

  • Not started: ❌
  • In Progress: ❌
  • Complete: ✅

The formula below will output a different emoji character based on the text value in the Status field.



For another example, a small business may want to generate different messages to push to their website regarding inventory status. Items that are in stock should display one message, while items out of stock should alert the customer so they can be put on a waitlist.

Using the same formula structure, we can conditionally output a different message based on inventory status.

  {Inventory}='In stock',
    "Item is in stock and available for purchase",
    "ℹ️ This item is on backorder, but will be back in stock soon"


An alternative to IF statements using SWITCH

IF statements work well for many cases, but an alternative to the IF statement is using the SWITCH function.

Was this article helpful?