Copy link to clipboard
Copied
Hello,
I am using the SUM function in calculated field to add and subtract values and display the results in a "Total" field. In order to make the subtraction work, the user has to enter a negative number in the "Losses" field. I would like to have the user just enter a number and have the field automatically change it to a negative number. Is there a way to do this, or should I be approaching this in a different way?
A negative number in a column where the color (sign) is negative would indicate a positive number.
I would perform the calculation using the subtract operator. This can be done in the Simplified or the Custom JavaScript options.
Copy link to clipboard
Copied
You can use a custom validate script to automatically make any positive numbers negative, something like:
// Custom Validate script for text field
// If the entered value when converted to a number is greater than zero...
if (+event.value > 0) {
// ...multiply it by -1 to convert it to a negative number
event.value = -1 * event.value;
}
Copy link to clipboard
Copied
Thank you for your quick response. You solution would definitely work, but I decided to use the Simplified function in the Calculated tab. Thanks
Copy link to clipboard
Copied
A negative number in a column where the color (sign) is negative would indicate a positive number.
I would perform the calculation using the subtract operator. This can be done in the Simplified or the Custom JavaScript options.
Copy link to clipboard
Copied
Thank you. I found a video online that explained how to simply add and subtract fields in the Simplified Java Script option.
Thanks.
Copy link to clipboard
Copied
OK, but consider what would happen if the user enters a negative number.
Copy link to clipboard
Copied
This a reduction of assigned personnel. Any addition would be listed as a gain in TO & E.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more