Frequently Asked Question (FAQ) Library
FAQ: Calculate Text Field (v1,0, 07/21/23)
Tags: Features Basic, Action Tags
The @CALCTEXT action tag evaluates specified logic for text fields and outputs the result as text. It is
usually used with an if (x,y,z) function, where if x is true, then y, else z.
Example #1: Conditional piping – used to customize lookback timeframes.
In the following example, we want to customize the timeframe for lookbacks at each event (visit). For the
baseline questionnaire, we will ask about medications prescribed in the past year. For the follow-up
questionnaire, we will ask about medications prescribed in the past month.
To perform a calculation on text fields with conditional piping, we will add a hidden field and use the
@CALCTEXT action tag to ‘calculate’ the text that will be used for piping based on the event.
a. Within the ‘Designer’ in the left navigation menu, add a text box field for the calculation.
b. In the action tag box, add the @HIDDEN and @CALCTEXT action tags. The @HIDDEN action tag will
hide the field on the form.
For the @CALCTEXT tag, add the following syntax:
@CALCTEXT(if([event-name]=’baseline_arm_1’, ‘in the last year’, ‘in the last month’))
The action tag box should look like this:
Notes:
i. You must use text box field type for @CALCTEXT calculations. Do not use calculated field type.
ii. In this example, a smart variable, [event-name], is used; however, project-specific variables
can also be used. In instances where the evaluated field is multiple choice, use the numeric
code for the choice you want to reference.
iii. When referencing the value of a text field, it must be contained within quotes or apostrophes.
iv. @CALCTEXT action tag can also be used without conditional logic. For example, it can be used
with other text functions to concatenate text or extract text from other text field.
How do I perform a calculation on text fields?
If the event is baseline,
the calculated value
will = in the last year
For all other events, the
calculated value will = in
the last month