0
votes

I am attempting to write a formula that will calculate an amount but if the serviceFee field has a value it will use that value.

So

Field1 = Amount
Field2 = ServiceFee

If ServiceFee has a value the amount must equal the servicefee
If any of the ClientTypes are matched the formula will not look at the ServiceFee

I have tried deploying this but the formula seems to execure the ServiceFee section only

IF(ClientType.Id = '123456', 
   Amount- Discount, 
   IF(ClientType.Id = '7891011', 
      Amount + 1,
      IF(NOT(ISBLANK(ServiceFee)), 
         Amount = ServiceFee, 
      )
   )
)
1
This formula is not valid and won't compile. Could you please include the formula you are currently using, verbatim?David Reed

1 Answers

1
votes

The problem is you are trying to assign Amount a value in the last statement, which doesn't work in formula syntax. It won't compile because that is actually parsed as a comparison statement (returning a boolean value).

Instead, first determine what the formula should return. If you have several Client Ids, try the CASE function. That way it's clear what happens in each of the scenarios. For example:

CASE(ClientType.Id,
  '123456',  Amount - Discount,
  '7891011', Amount + 1,
  IF(ISBLANK(ServiceFee), 0, ServiceFee)
)

The last argument is the default of the CASE function and will be evaluated if ClientType.Id isn't either of the previous values.