Skip to main content
Participant
Oct 31, 2018 6:42 PM UTC
Answered

I have a field that is the sum of 3 other fields. How do I leave the field blank if the value is zero?

I have a field that is the sum of 3 other fields. How do I leave the field blank if the value is zero?

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Oct 31, 2018 7:48 PM UTC

Are you using a script for the calculation, or something else?

If you're not using a script, you'll need to. The basic code to achieve it is:

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

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

var v3 = Number(this.getField("Text3").valueAsString);

var total = v1+v2+v3;

event.value = (total==0) ? "" : total;

2 replies

Participant
Nov 1, 2018 1:34 PM UTC

Thank you worked like a charm.

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Oct 31, 2018 7:48 PM UTC

Are you using a script for the calculation, or something else?

If you're not using a script, you'll need to. The basic code to achieve it is:

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

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

var v3 = Number(this.getField("Text3").valueAsString);

var total = v1+v2+v3;

event.value = (total==0) ? "" : total;

Translate