If the result of a calculation has a currency symbol or a percentage symbol the custom formatting script will not work. You need a script to convert the formatting back to a numeric value with no currency symbol of percentage symbol.
var nDec = 2; // number of decimal places to display
var sepStyle = 0; // style for thousand and decimal separators;
var negStyle = 0; // style to display negative numbers;
var currencySymbol = "$"; // currency symbol to use;
var currencyPrepend = true; // pre-pend the currency symbol
if(event.value == 0) {
// value is zero;
event.value = ""; // set value to null string;
currencySymbol = ""; // set currency symbol to none;
AFNumber_Format(nDec, sepStyle, negStyle, "", currencySymbol, currencyPrepend); // format result;
} else {
// non-zero value, format as variables are set;
AFNumber_Format(nDec, sepStyle, negStyle, "", currencySymbol, currencyPrepend);
}