Skip to main content
Participant
October 21, 2024
Answered

Simplified Notation - what am I doing wrong?

  • October 21, 2024
  • 2 replies
  • 616 views

I have two fields:  Listings (currency format) & TotalListings1 (numberformat)

 

Trying to get a 3rd field (HomeValueAvg - currency format) to calculate:

 

=Listings/TotalListings1

 

But nothing appears in the calculated field.   I don't do many forms, but I've done some searching & none of the solutions I've found have helped.  I had spaced in some of the field names, but removed those. 

 

 

 

 

This topic has been closed for replies.
Correct answer try67

There's another issue with your formula. When TotalListings1 is empty (or if it equals zero) you will get an invalid operation, as you'll be dividing by zero. If your field's Format is set to Number you will get an error message in such cases. If it's set to None it will show up as Infinity. Either way, not a good outcome.

To prevent this from happening you need to use a script to perform the calculation, like this:

 

 

var v1 = Number(this.getField("Listings").valueAsString);
var v2 = Number(this.getField("TotalListings1").valueAsString);
if (v2==0) event.value = "";
else event.value = v1/v2;

 

 

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
October 21, 2024

There's another issue with your formula. When TotalListings1 is empty (or if it equals zero) you will get an invalid operation, as you'll be dividing by zero. If your field's Format is set to Number you will get an error message in such cases. If it's set to None it will show up as Infinity. Either way, not a good outcome.

To prevent this from happening you need to use a script to perform the calculation, like this:

 

 

var v1 = Number(this.getField("Listings").valueAsString);
var v2 = Number(this.getField("TotalListings1").valueAsString);
if (v2==0) event.value = "";
else event.value = v1/v2;

 

 

KJIAAuthor
Participant
October 22, 2024

That's exactly what happened, and thank you so much for the additional detail.  I've applied it in all of the fields & it's working perfectly!

PDF Automation Station
Community Expert
Community Expert
October 21, 2024

Remove the = sign.

KJIAAuthor
Participant
October 21, 2024

Well don't I feel silly.  I thought I had tried that, but now it works.  I have the = sign in another calculated field and it's working.  Go figure.  Thanks!