2 Replies Latest reply on Mar 31, 2012 10:05 PM by philmodjunk

    Multiple Tests in IF Statement?

    smallbusiness

      Title

      Multiple Tests in IF Statement?

      Post

      I would like to be able to print foreign address labels. Some countries put the postal (zip) code before the city, some after the city.

       

      What I am trying to do is an IF-type statement, that evaluates the country, then delivers the city line either as postal code, city or city, postal code.

       

      Idea (but this test does not work) would be: IF (country = "USA" or "Canada" or "Mexico" ; city & state & zip ; zip & city )

       

      Any ideas how to do this efficiently? Thanks!

        • 1. Re: Multiple Tests in IF Statement?
          davidanders

          The CASE statement for a calculated field or script step is generally preferred over a nested IF statement. Easier to read and manage.

          These threads should help understand the usage and logic...

          Google "case statement site:forums.filemaker.com"
          https://www.google.com/search?q=case+statement+site%3Aforums.filemaker.com

          David Anders
          The Computer Guy, Seattle

          • 2. Re: Multiple Tests in IF Statement?
            philmodjunk

            You can use the case function written like this:

            Case (country = "USA"  ; city & state & zip ;
                      country = "Canada"  ; city & state & zip ;
                      country = "Mexico"  ; city & state & zip ;
                      zip & city )

            Or you can stay with the If function:

            IF (country = "USA" or country = "Canada" or country = "Mexico" ; city & state & zip ; zip & city )

            You can even be a bit more creative by using Pattern count to make the expression a bit simpler:

            IF ( patterncount ( "USA Canada Mexico" ; country ) ; city & state & zip ; zip & city )

            All three of these functions can be looked up in FileMaker help if you want to learn more about how they work.