Start a conversation

Compare several numerical variables against a specific variable

Check out the article Using the "for loop" in calculations to see an explanation about how this calculation works. This template allows you to compare three or more fields (variables) with one specific field. You can also add extra variables to the list if you have more than 3, just by separating them with a comma:

var main = {main_variable};
var array = [{var_1}, {var_2}, {var_3}];

for  (var i=0; i < array.length; i++) {
    var tempVar = array[i];
    if (tempVar > main) {
        tempVar + " is greater than " + main + ". Please check all the fields."
    }
}

Note: {main_variable} is the variable against which variables {var_1}, {var_2}, {var3} will be compared - replace these names with your own variable names.

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

  2. Posted
  3. Updated