Execute the calculation if not all variables have been filled in with in EDC/CDMS
Table of Contents
One of the messages that we might frequently see in our calculations is "Not all values for this calculation are available (yet)" (see Calculation errors). The message indicates that not all fields that are used in the calculation contain values. It can be inconvenient to see it on screen, especially in surveys. In this article we explain how you can hide this message, until all the relevant variables have been filled in.
It is important to note that:
- this method is useful if the variables involved are mandatory
- if zero (0) is an expected value in one of the fields, the arguments in the if-clause need to be modified
- the calculation will work for all types of variables except for grid fields and checkboxes
The calculation
The rationale is to replace the empty fields with a zero (0). Then, use an if-else statement to check first if all our variables contain values that are different to 0. If they do, the desired calculation will execute (for example, the difference between two dates). While one of the dates has not been filled in (i.e. there are zeros), no message will be displayed in the calculation - field 3.3 in our example above.
In this example, the calculation would be as follows:
'##allowempty##'; '##setemptytozero##'; if('{DOB}' == 0 || '{CurrDate}' == 0){ ""; } else{ getDateDiff('{CurrDate}','{DOB}','y'); }
And this would be the outcome: