4 Replies Latest reply on Dec 7, 2014 10:34 AM by amr7020

    Case function multiple parameters

    amr7020

      Title

      Case function multiple parameters

      Post

      Im trying create a calculation which I inter the first and second columns and I get the speed calculated 

      I start with this calculation 

      Case ( Direction= "E" and TPAB  ≤ 59 ; "No Restriction" 

      but I can't figure the rest out 

      Ill appreciate if some one could help me 

      Thanks

       

      Screen_Shot_2014-11-29_at_2.33.42_AM.png

        • 1. Re: Case function multiple parameters
          jbante

          With the Case function, the arguments alternate between a condition to test, and the result to return if that condition is True. Based on your table screenshot:

          Case (
          TPOB ≤ 59 ; "No restrictions" ;
          TPOB ≤ 79 and TPDBA ≤ 500 ; "No restrictions" ;
          TPOB ≤ 79 ; "25 MPH" ;
          TPOB ≤ 99 and TPDBA ≤ 500 ; "35 MPH" ;
          TPOB ≤ 99 ; "25 MPH" ;
          // etc.
          )

          I'm not sure what "Direction" has to do with the conditions, since it doesn't appear in your screenshot.

          One thing to note is that the Case function tests the conditions in order, returns the result for the first condition that evaluates as True, and skips the rest. When testing a series of contiguous numerical ranges like this, we can use this behavior to abbreviate our syntax some: because we already tested all possibilities for TPOB < 80, our conditions for the range 80-99 actually only need to check TPOD ≤ 99, not TPOD ≥ 80 and TPOD ≤ 99.

          What are you using this for, and where did this table come from? These conditions look like the kind of thing that may be likely to change at some point, but where any historical record may need to reflect what the requirement was at the time rather than what it changed to. If so, this data should probably be set to a stored (non-calculation) field by a script, rather than just using a calculation field.

          • 2. Re: Case function multiple parameters
            amr7020

            Thank you very much for the help, Im trying to use this calculation for a Railroad solution, I'm going to post the whole table which is going to explain why direction is important, I understand the Case function more after I take a look at your calculation, Unfortunately there is no book or tutorial that explain these functions in depth, I'm a beginner in Filemaker so I only know the very simple scripts, if you take a look at the big picture here and let me know if there is better way to get it done, Thank you again for the help.

            • 3. Re: Case function multiple parameters
              RickWhitelaw

              The FileMaker Help does a pretty good job at explaining functions. One thing to remember is that functions are very specific, so each one has a limited definition and scope. What's not explained in depth in Help, as one example, is the nesting of functions. That said, there are a number of excellent books out there. I started on version 8.5 and at the time the FileMaker Bible was a great source of info for me. 

              • 4. Re: Case function multiple parameters
                amr7020

                Thank you very much Jeremy and Rick, I start to read the FileMaker Bible, its very helpful.