Calculation inside calculation?

Recommended Posts

TOTAL= MSRP - (MSRP * DISCOUNT)  - CC FEES) - COST

This is how I thought it would go in my head but I'm obviously doing this wrong. I have no clue about nested operations with parentheses.

The goal is to output the MSRP amount minus the discount amount...say 25% then pass that number to the CC Fees which is say 2.25...then subtract the cost and end up with the total.

eg: MSRP= 100 Discount = 25% = 75.00 - CC Fees which are 1.69 on the 75.00 - the Cost which is 45.00 leaving a total of 28.31

Trying to do this all in one calculation.

Share on other sites

Well, if:

MSRP  = 100
Discount = 25%
CC Fees = 1.69
Cost = 45

then:

`MSRP - MSRP * Discount - CC Fees - Cost `

will return 28.31. Although I would prefer to write it as:

`MSRP * ( 1 - Discount ) - CC Fees - Cost`

--

Share on other sites

I understand Please Excuse My Dear Aunt Sally....what I don't understand is if there's a way in FMPro to store a calculated value within the same calculation to be evaluated by other parts of the statement?

ie: The CCFees aren't able to be calculated until the (MSRP * Discount) occurs. So if MSRP=100 and the Discount is 25% then the amount that ends up being charged is actually 75.00 and within the same calculation the CCFees would be calculated based on the 75.00 and added and then the Cost subtracted? I don't actually have a field called CCFees..I was just using that name as an example. CCFees doesn't have a known value until the MSRP*Discount is calculated within the same statement. Am I making any sense or am I talking myself in circles? I thought some sort of nested argument could be used within the same statement?

Share on other sites

If I understand this correctly (and that's a very big if), you want to do:

`MSRP * ( 1 - Discount ) * ( 1 - FeeRate) - Cost `

Which could be rewritten to be more readable as:

```Let ( [
charge = MSRP * ( 1 - Discount ) ;
fee = charge * FeeRate
] ;
charge - fee - Cost
)```

If you populate the FeeRate field with the value of 0.0225, the result will be 28.3125 for both.

Resist the urge to hard-code the fee rate into the calculation formula.

Edited by comment

Share on other sites

Does Fee Rate = CCFees in your answer? And I noticed the addition of brackets into your calculation, what's the effect of the brackets in this calculation?

Edited by OneStop

Share on other sites
6 minutes ago, OneStop said:

FeeRate is a field that will hold the fee rate  - i.e. the percentage of the charge that will constitute the fee amount.

9 minutes ago, OneStop said:

what's the effect of the brackets in this calculation?

Well, what do you think?

Share on other sites

Well my assumption is that it defines

``` [
charge = MSRP * ( 1 - Discount ) ;
fee = charge * FeeRate
] ```

as a local variable that can then be evaluated by

`charge - fee - Cost`

but as I stated I don't actually have a field in my layout containing the Fee Rate/CCFees...is that something that I need to create in order for FMPro to evaluate this properly? I had every intention of hard coding the CCFees as this entire system will be blown out by a RoR solution. I'm building this as a stop gap at the moment...

I'm a PHP/MySQL guy so the syntax of FMPro is a little strange to me at times and it seems to have some weird rules I can't quite work out. Sorry to be so dense...

Edited by OneStop

Share on other sites
11 hours ago, OneStop said:

I had every intention of hard coding the CCFees as this entire system will be blown out by a RoR solution. I'm building this as a stop gap at the moment...

You can replace FeeRate with the actual rate (number). But if you ever need to change the rate, it will affect all your records, not just the future ones.

Share on other sites

OK so what I've is this:

Let ( [
charge = MSRP * ( 1 - Coupon Discount ) ;
fee = charge * .0225
] ;
charge - fee - Price
)

Using a real world example, I have a product whose MSRP is 238.16. The Price/Cost is 150.16. The CCFee is .0225. The Coupon Discount is 25%. I created a Coupon Discount number field with a value of .25 displayed as a percentage.

So if you subtract 25% from the MSRP that would be \$178.62 + 2.25% CC FEE would be \$182.64 minus the Price/Cost of \$150.16 should leave a total of \$32.48.

However, in my DB the total is showing as \$24.92? Where am I going wrong?

Share on other sites

It's difficult to follow your explanation, because you use inconsistent terms. Price is not the same thing as Cost - and Price/Cost is yet another.

Also, so far you have been subtracting the fee, now it seems you want to add it. If I take the following formula:

```Let ( [
charge = MSRP * ( 1 - Coupon Discount ) ;
fee = charge * .0225
] ;
charge + fee - Price
) ```

and plug in the following values:

MSRP  = 238.16
Coupon Discount = .25
Price = 150.16

the result will be 32.47895.

Share on other sites

Sorry, in an attempt to rectify the confusion between the terms Price and Cost I combined them to intimate that they were in fact interchangeable. What the vendor refers to as Price is actually the Cost. Price to me sounds like the selling Price to the customer when in fact it's the Cost to the reseller. Sorry for the confusion. In the midst of doing so I managed to confuse myself. The first calculation is correct, the CC Fees absolutely should be subtracted as you wrote.

Thank you so much for your help. I learned something else again today.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×
×
• Create New...