4 Replies Latest reply on Apr 11, 2012 9:27 AM by philmodjunk

    If Statement with Multiple Variables

    MJ_2

      Title

      If Statement with Multiple Variables

      Post

      HELP.  I can't get the following If ( test ; resultOne ; resultTwo ) to work.

      I'm trying to say If client selects "Double Inside" option, then the fee is $1,000...If "Double Oceanview", then the fee is $1,200...If "Triple Oceanview", then the fee is $1,175...If "Quad Oceanview", then $1,100.  

       

      This is what I entered...

      If ( Cabin Type = "Double Inside" or "Double Oceanview" or "Triple Oceanview" or "Quad Oceanview" ; 1000; 1200; 1175; 1100)

      However, I received an error message, please advise.

      Thanks in advance.

        • 1. Re: If Statement with Multiple Variables
          Sorbsbuster

          A common errorr, and understandable.  You have to enter the IF query as:

          IF ( Cabin Type = "Double Inside" or Cabin Type = "Double Oceanview" or Cabin Type = "Triple Oceanview" or Cabin Type = "Quad Oceanview" etc...

           

          But the rest of your outcomes suggest that you need a Case Statement (which is generally more versatile than an IF, anyway)

          Case (

          Cabin Type = "Double Inside" ; 1000 ;
          Cabin Type = "Double Oceanview" ; 1200 ;
          Cabin Type = "Triple Oceanview" ; 1175 ;
          Cabin Type = "Quad Oceanview" ; 1100 ;
          0

          )

          • 2. Re: If Statement with Multiple Variables
            MJ_2
             Thanks a million.  I'll try this...
            • 3. Re: If Statement with Multiple Variables
              MJ_2

              It worked....THANKS!

              • 4. Re: If Statement with Multiple Variables
                philmodjunk

                It works, but you may want to set up a table where you have one record for each of these options an their prices and use a relationship so that the price can be looked up automatically when you select a value for cabin type.

                With such a pricing table, you can change your rates in the future by updating values on a layout rather than be redefining your calculation field to contain new numbers--which requires developer access and will change the prices of your past cabin rental records to use the new rates---which messes up your business records.