Skip to main content
Participating Frequently
February 27, 2020
Question

Calculation not to exceed a certain amount

  • February 27, 2020
  • 1 reply
  • 1969 views

I am trying to create the following calculation.

 

Required number of credits- credits completed= credits needed.

 

What I need to have happen is for the total not to exceed the required number of credits but still show a total if the the difference is less than the required number of credits- credits completed.

 

I used the following equation for it not to exeed the required number of credits, but if the balance of credits needed is less than the required credits, it only shows the max number allowed.  

 

var v1 = Number(this.getField("30").value);
var v2 = Number(this.getField("ABENGCOMP").value);
event.value = Math.max(30, v1-v2);

 

The highlighted section in the image below shows where the issue is.  The totals on these should be 5 and 3, respectively.

 

 

Thanks in advance.

This topic has been closed for replies.

1 reply

try67
Adobe Expert
February 27, 2020

Use Math.min, not Math.max...

drochaAuthor
Participating Frequently
February 27, 2020

I changed max to min but still not getting the results I need.  Both should read 5 in the credits needed column.

 

 

Thanks

try67
Adobe Expert
February 27, 2020

Can you share the actual file with us? You can attach it to the original message using the tiny paperclip icon at the bottom when you edit it, or upload it to a file-sharing website (like Dropbox, Google Drive, Adobe Cloud, etc.), generate a share link and then post it here.