Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Percentage help

Avatar

Former Community Member
I have a form where I need to add the dollar amounts for projected small business spend and large business spend. (which is entered by the user) Then, actual cumulative smal and large spend is also entered by the user.



I need to know how to write the script for calculating the percentage of cumulative spend in relation to projected spend.



cumulative spend = % of projected spend

Projected spend = 200.00

50.00 is what % of 200.00



Here is the code I tried:



if(TotalCurrent ne 0) then

(SmallActual / TotalCurrent) * 100

else

null

endif



Here is the error:



Script failed (language is formcalc; context is

xfa[0].form[0].topmostSubform[0].Page1[0].SmallActual[0])

script=endif

Error: syntax error near token 'endif' on line1, column 5.



Any help is appreciated. I am new to this program.
2 Replies

Avatar

Level 3

Can you send me the form so I can review it and help?

Thanks.

Avatar

Level 6

This is javascript:

if (TotalCurrent.rawValue != 0) {

(SmallActual.rawValue / TotalCurrent.rawValue)*100;

} else {

// Set field to blank (or whatever else you would want) here

}