standard math function

F

felix1093

Probably a dumb question, but I am new in Infopath, I'm trying to anyway
develop a report for my company.
In a field, I am computing the Net Loss after insurance value. The insurance
value is , let's say 100 USD, so, if the Loss is above this value, the
NetLoss = Loss - 100, and if Loss is below 100, NetLoss = Loss.

In total, a good formula is: NetLoss = Loss - max (Loss - 100,0)

How can I compute this in a field, since all math functions appear to only
relate to repetitive fields from tables?

Regards,

FH
 
K

KjellSJ

Add an 'Expression box' control for your NetLoss field and the function (fx)
button for the 'XPath' field in the poup dialog. Enter your formula "Loss -
max (Loss - 100)", verify it and click OK twice.
 
F

felix1093

Thanks for your reply.
Unfortunately I did not succeed to implement the max(0,Loss-100) function.
Can you copy/paste the expression with Xpath?

regards,
 
K

KjellSJ

You're quite right that you cannot use max() on two separate fields.

As an alternative, use rules on the Value and Loss fields to set the value
if the NetLoss field. You will need to have two rule conditions, one for when
Loss>Value (1), and one for when Value>=Loss (2). Setting the NetLoss will
then be either (1) =Loss-Value or (2) =Loss.

You could also use OnAfterChange scripts on the same fields to do the
calculations.

Note that in both solution your user will have to actually change the
content of one of the fields to trigger the calculation.

KjellSJ (http://kjellsj.blogspot.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top