Forum Discussion

MikeKlausing's avatar
MikeKlausing
Qrew Assistant Captain
6 years ago

Multiple conditions formula to generate cost field

I am looking to generate a cost field for "freight" where its based on miles away. 

If (([Miles]>0 but <=150), "$450. ([Miles]>150 but <=200), "$600")

I am unsure if an "IF" formula works in this case or what Function I need to use. 
  • If (
    [Miles]>    0 and [Miles  <= 150, "$450,
    [Miles]>150 and [Miles] <= 200, "$600",

    .. then a value for when Miles is > 200)

  • MikeKlausing's avatar
    MikeKlausing
    Qrew Assistant Captain
    Perfect, that works great. 

    Thanks for the quick reply as always Mark.
  • This can be done in a Case statement.  The formula stops when the first match is found.  Try something like this:


    Case(True,
      [Miles]<=0, 0,
      [Miles]<=150, 450,
      [Miles]<=200, 600,
      0
    )

    The last zero is what's returned if nothing else matches.  (You didn't specify what should happen if miles > 200.)