Jump to content

Calculate Shipping Costs - Updated


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

Recommended Posts

I got a very helpful reply here once regarding calculating shipping costs using this formula:

 

Case (
BillableWeight ≤ 1 ; 8.99 ;
BillableWeight ≤ 10 ; 8.99 + 0.5 * BillableWeight ;
9.99 + 0.4 * BillableWeight
)

 

Not however, the terms have changed and I need to evaluate charges that are BETWEEN certain values....

For instance: ≤ 1 ; 8,99 ; is no longer true...

Now it's .01 - .69 = 4.99 etc...

How would I go about modifying the calculation to evaluate between two values instead of less than a value?

Link to comment
Share on other sites

1 hour ago, comment said:

 So you only need to arrange your boundaries in ascending order.

Explain Like I'm 5?

 

Here's the new formula for the shipping rates...

 

0.01 - 0.69 lbs = $4.99
0.70 - 0.99 lbs = $5.79
1.00 - 8.00 lbs = $5.99 + .80 per lb

 

I understand evaluating something like ≤ .70 ; $4.99

But I'm not understanding how I would get to  >.70  ≤  .99 ; 5.79 ;

In order to evaluate the new pricing structure I have to be able to define a cost as being between two sets of weights instead of just being less than X.

Edited by OneStop
Link to comment
Share on other sites

24 minutes ago, OneStop said:

Like I'm 5?

I am afraid you will need 2nd grade math for this - but I will try...

Consider this:

Case ( 
BillableWeight ≤ .5 ; "A" ; 
BillableWeight ≤ 1 ; "B" ; 
BillableWeight ≤ 5 ; "C" ; 
BillableWeight ≤ 10 ; "D" ; 
"E"
)

What this means is that:

  • when BillableWeight is between 0 and 0.5, the result will be "A";
  • when BillableWeight is between 0.5 and 1, the result will be "B";
  • when BillableWeight is between 1 and 5, the result will be "C";
  • when BillableWeight is between 5 and 10, the result will be "D";
  • when BillableWeight is above 10, the result will be "E".

Why? Because when BillableWeight is say 4, the first test returns false: 4 is not ≤ .5. The next test,  BillableWeight ≤ 1, also returns false. The third test returns true, and the result will be "C" as expected, since 4 is between 1 and 5.

So our Case() statement does evaluate if the given input falls BETWEEN 2 boundaries; but we only need to list each boundary once (provided we do so in the correct order).

  • Like 1
Link to comment
Share on other sites

Huzzah!

Quote

Why? Because when BillableWeight is say 4, the first test returns false: 4 is not ≤ .5. The next test,  BillableWeight ≤ 1, also returns false. The third test returns true, and the result will be "C" as expected, since 4 is between 1 and 5.

This is the part that I was missing. I mistakenly thought that when the BillableWeight was say "4" in your example....That both statements of  ≤ 5 and ≤ 10 would both return true.

So is that in this calculation FMPro will just evaluate to the first true statement and then stop?

Link to comment
Share on other sites

Both statements would return true - but the evaluation will never get to the second statement, because it will exit as soon as it finds one that is true. That's why the order of tests is so important.

Quote

The Case function evaluates each test expression in order, and when a True expression is found, returns the value specified in result for that expression.

(Emphasis mine)

Link to comment
Share on other sites

This topic is 1981 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.