Start a conversation

Compare two variables in calculations

In calculations, you sometimes need to compare two variables against each other. Check out the article Using the "if-else" logic to see how this works.

For example, you want to check if one value is larger than the other and then show an error message if the condition is true. 

Below is an example that allows you to check if the diastolic blood pressure (diasbp) is larger than the systolic blood pressure (sysbp). 

var dbp = {diasbp};
var sbp = {sysbp};

if(dbp > sbp){
} else {

You can also use the following operators to compare two variables (instead of '>'):

  <   smaller than
  >   larger than
  ==  equal to
  !=  not equal to
 >=   greater than or equal to
 <=   less than or equal to

The calculation returns 1 if the dpb is larger than the sbp and 0 if not.  To set up a validation message message, use this setup:

  • If this field is equal to 1 
  • Show an error (or other type of) message. 

You can find a similar calculation here.

Choose files or drag and drop files
Was this article helpful?
  1. Castor Support Team

  2. Posted
  3. Updated