Skip to main content
whitneyr123
Participant
January 31, 2017
Answered

Help writing custom calculation similar to an IF stmt in excel.

  • January 31, 2017
  • 1 reply
  • 400 views

Hi! I need help writing a custom calculation.  Basically, If Box 1>Box 2, then value should be Box 1- Box 2.  Otherwise, box should be blank. How do I do this?

This topic has been closed for replies.
Correct answer try67

var v1 = Number(this.getField("Box 1").valueAsString);

var v2 = Number(this.getField("Box 2").valueAsString);

if (v1>v2) event.value = v1-v2;

else event.value = "";

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 31, 2017

var v1 = Number(this.getField("Box 1").valueAsString);

var v2 = Number(this.getField("Box 2").valueAsString);

if (v1>v2) event.value = v1-v2;

else event.value = "";