Jump to content

Calculation inside calculation?


This topic is 2632 days old. Please don't post here. Open a new topic instead.

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.

Link to comment
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?

Link to comment
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
Link to 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
Link to comment
Share on other sites

6 minutes ago, OneStop said:

Does Fee Rate = CCFees in your answer?

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?

Link to comment
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
Link to comment
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.

Link to comment
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?

Link to comment
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.

 

 

Link to comment
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.

Link to comment
Share on other sites

This topic is 2632 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.