Text calculations are written in the same way as simple calculations; however, a Text calculation returns a result in text (string) format.
Example 1: nested if statements
Nested if statements are often used for Text calculations because they allow you to check for multiple conditions sequentially and return a value based on one of those conditions being met. The image below shows an example of a nested if statement in a Text calculation to calculate which sprint time was faster.
The equation in this example first checks if Sprint 1 is less than (i.e. faster) than Sprint 2. If it is, it returns the text string Sprint 1. If not, it performs a second if statement, which checks if Sprint 2 is less than Sprint 1. If it is, return the text string Sprint 2. If it isn’t, then they must be equal, so the calculation returns Tie.
In this example, you could also use an Option calculation and set Sprint 1, Sprint 2 and Tie as options. An Option calculation may be a more preferable option than a Text calculation if you want to apply performance standards to the field, use the field as a criterion in a performance alert or filter reports based on the options.
Example 2: return date as a string
Another example of how a Text calculation can be used is to convert a date into a text string. This example re-formats a Date field into text using the date function to return the weekday.
In this example, the equation in the Latest Treatment Day calculation converts the format of the Latest Treatment Date from MM-dd-yyyy format to EEEE. The result indicates that May 4th 2022 fell on a Wednesday.