LOGICAL FUNCTIONS IN CALCULATED FIELDS
You have already seen some examples that demonstrate how powerful calculated fields can be for creating useful measures and dimensions. But you can do even more with calculated fields. This section will introduce you to the use of application logic, including if‐then statements that you may be familiar with from various programming languages.
Case Discrimination
Imagine your sales data is recorded by geographic region, as in the Superstore dataset, but you would like to report the numbers by the sales reps assigned to the different regions. This is easily done with a CASE
statement.
Create a new calculated field, name it Sales Rep
, and enter the formula from Listing 4.2.