Question

I am trying to calculate the interest rate for a legal form I am creating at work. In order to get that rate you need to take the current balance X legal rate of interest X 0.01 / 365. Here is what I have currently written that is not calculating correctly.

{={Principal}-{Paid}*{InterestRate}*0.01/365}

When I run the mergefield "as is", on our test account that has a principle balance of 5,000 a paid balance of 0.00 and an interest rate of 10%(10.00) it comes out = 5,000 instead of 1.36.

I have searched forums and the Microsoft's support site and stackoverflow and only found info on what operators are allowed and examples of basic syntax of addition, subtraction, and division. None that where showing a combination of these. Can you please be another set of eyes and help me see where my syntax is incorrect?

Was it helpful?

Solution

This has to deal with order of operations. In this example, {Paid}*{InterestRate}*0.01/365} is executed first (multiplication/division), then the subtraction takes place.

Just add parens around {Principal}-{Paid} and it should work.

{ = ( { Principal } - { Paid } ) * { InterestRate } * 0.01 / 365 }

OTHER TIPS

You will get a syntax error if the Regional Settings in Windows Control panel (or in Mac System Preferences) have, e.g. £ instead of $ as the currency symbol. To avoid that, you can try something more like

{ SET myPrincipal { MERGEFIELD Principal } 
}{ SET myPaid { MERGEFIELD Paid } 
}{ SET myInterestRate { MERGEFIELD InterestRate } 
}{ =(myPrincipal-myPaid) * myInterestRate * 0.01 /365 }

If you have mixed currencies, that may end up showing a currency symbol where the symbol matches the control panel setting, and a plain number where it doesn't. Adding a \#0.00 to the end of the { = } will probably fix that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top