Creating If-Then-Else Formulas

Objectives

After completing this lesson, you will be able to:

  • Modify data display using If-Then-Else formulas

Overview of Control Structures

Learn how to use functions in a formula.

Formulas without control structures execute each expression in the formula exactly once when the formula is evaluated. The expressions are executed in a sequential fashion, from the first expression in the formula to the last.

Control structures enable you to allow some flexibility. Depending upon which control structure you choose, you can skip over some of the expressions or you can repeatedly evaluate some expressions depending on a condition.

Control structures are the primary means of expressing business logic. Typical report formulas make extensive use of them.

If-Then-Else Formula Overview

Implementing a condition using If-Then-Else.

Parts of an If-Then-Else Formula

If-Then-Else formulas have the following three parts:

  • If — Sets the condition or test

  • Then — Sets the action to be taken if the condition is met, that is, if the test returns a true value

  • Else — (optional) Sets the action to be taken if the condition is not met, that is, if the test returns a false value

Creating an If-Then-Else formula

Suppose that you want to display a rating beside each customer’s order figures in an orders report depending on the level achieved: high orders or low orders. You can accomplish a task such as this by using an If-Then-Else formula.

Code snippet
If {Orders.Orders Amount} > 40000 Then
 "High orders"
Else
 "Low orders"
Expand

Hint
The data type must be the same for the Then and Else parts of the formula (text, numeric, date). For example, if the Then part of the formula prints a text string, the Else part of the formula must also print a text string.

Log in to track your progress & complete quizzes