Models Formula Reference / If / Then / Else

If / Then / Else

If/Then/Else statements are extremely useful if you want to set a condition and have two results: one if the result is true, and a second if the result is false.

In Pry, there are two ways to format an If/Then/Else statement:

  1. Using the pre-built IF function
  2. Using a conditional expression

Using the pre-built IF function

When creating a formula in Pry, you can reference our pre-built IF function by typing in “IF” and selecting it from the drop-down bar:

After referencing the function, you can create your If/Then/Else statement with the following format:

Where:

  • Input 2 = Value if the condition is true
  • Input 3 = Value if the condition is false

Using a conditional expression

The other option you can use to create an If/Then/Else statement in Pry is by creating a conditional expression with the following format:

Where:

  • Input 2 = Value if the condition is true
  • Input 3 = Value if the condition is false

Condition syntax

Use the following syntax to create condition statements:

Use cases

Here are some examples on how to create If/Then/Else statements with the pre-built IF function and with conditional expressions.

Keeping track of actual customers

In this example, we are using an If/Then/Else statement to keep our number of customers accurate with actual data and use it to forecast future customers. "Actual Customers" is a list variable of our historical customers each month. This If/Then/Else statement is checking that if "Actual Customers" is greater than zero in the current month, then use that value from the list for the formula "Customers" — but if "Actual Customers" is equal to or less than zero, use the previous month's value for "Customers" plus the current month's expected value for "New Customers" minus the current month's expected value for "Churned Customers" to find the number expected customers in the month.

Tip
You can apply the same logic to keep track of your New Customers and Churned Customers

Utilizing month variable

In this example, we are using an If/Then/Else statement to track our expected customers after our product launch date. The "Month Value" is a prebuilt variable that outputs the current month and year. We created a date input for our product launch date and a number input for our expected number of new customers every month. For our If/Then/Else statement, the condition we are checking is if the current month is on or after the “Product Launch Date”. If this condition is true, we’ll use the value for our “Monthly New Customers”; if the condition is false, we’ll use zero.