Logic in a calculation

Hi All,

I am working on an app where I “might” need to change the value of a field based on a calculation and some logic. I have an Invoice with Line items showing in a table element. Outside of the table, the sum of several columns is calculated.

Each item is a service I provide. The customer has a maximum number of services they will pay for per invoice. Sometime I need to perform more then the MAX. I want the line to show up to show we did the work even tho they are not paying for it.

I currently have a field for Price, ActualSvc, and Etended price for each line item. I currently calculate the extended price per line item then total that field outside the table along with the ttal ActualSvc. A field called MaxSvc is available on teh customer outide of the table.

So I am looking for a way to:

If ActualSvc > MaxSvs then Totalprice = MaxSvs * Price else TotalPrice= ActualSvc*Price This amount would be saved on the Invoie, not the line item.

Any idea how to go about this? Thanks in advance.

In Excel it would be =IF(ActualSvc<MaxSvc,PriceActualSvc,PriceMaxSvc)

If I understand correctly, you want to write a value that dynamically changes based on some conditions.

This is where :formatastext comes in very handy. I use it all the time for complex values and it works like a charm

for example of you want to store the Total Price: (I will assume this is a number field)
When you create the invoice…
TotalPrice = [ActualSvc > Max Svc: format as text]

you will get 2 boxes → Yes and No

In yes you will put the equation: MaxSvs * Price

In No you will put: ActualSvc*Price.

Okay, now you have the value but it’s a text, so just do: convertedtonumber

it should look something like this:
[ActualSvc > Max Svc: format as text:convertedtoanumber]

1 Like

I don’t think I was clear in my explaination

TotalPrice = The lesser of ActualSvc or MaxSvc times the Price.
So if the ActualSvc is 8 and theMaxSvc is 2 and price is $120, then the TotalPrice will only = 2 x $120 = 240

In Excel it would be =IF(ActualSvc < MaxSvc, Price x ActualSvc , Price x MaxSvc)

Yep, still following the method above will work, you just need to adjust for your specific formula but that is the start on how you will arrive to the number

This topic was automatically closed after 70 days. New replies are no longer allowed.