2 Replies Latest reply on Feb 6, 2010 9:38 PM by beckett85_1

# Help Creating a "Case Function", I believe?

### Title

Help Creating a "Case Function", I believe?

### Post

Hey Gang,

Trying to create more complex functions is over my head.  I *THINK* what I'm trying to do is create a "case" function, based on a series of tests.

I'm building a database to host the Net P&L on an e-biz ... and the Net P&L is calculated different based on what marketplace an item sell in.

Some marketplaces have the merchant fee built-in, but others where we use our own merchant processing have the fee as a separate transaction.  I'm trying to build a function that will calculate the "Merchant Fee" field, when there is one.

Marketplace Field:
Store1

Store2

Store3 *

Store4 *

*Store3 and Store4 have a merchant fee added to the transaction.

How do I build the function so that I am saying:
If the Marketplace Field is = Store3 or Store4, the merchant fee is the Gross * .029 + \$.30, and if the Marketplace Field is Store1 or Store2, the merchant fee = \$0

In other words ... using 3 fields:
Marketplace
Gross (total money on the order)
Merchant Fee (calculation of 2.9% plus \$.30, but ONLY if the Marketplace Field is one of the Stores that incur a merchant fee)

I hope that makes sense.  If someone could help write out the formula below, I'd be very grateful!

• ###### 1. Re: Help Creating a "Case Function", I believe?
I'd suggest you define a table of Merchants - then lookup the fees from there.
• ###### 2. Re: Help Creating a "Case Function", I believe?

Dont think you really need a case function, what you would do

if(or(table::field = "store 3"; table::field = "store 4");gross * .029+.3;0)

basically stating if its store 3 or 4, show the merchant fee, if you had more stores with diff fee's you could do the following with a case

Case(

if(or(table::field = "store 3"; table::field = "store 4");gross * .029+.3;

if(or(table::field = "store 5"; table::field = "store 6");gross * .039+.4;0)

that will return a merchant fee for .029 + .3 for store 3 or 4
.039 + .4 for store 5 or 6, any or store will return 0, hope it helps