2 Replies Latest reply: May 15, 2014 9:54 AM by Grant Perkins RSS

    Filter, compound expressions

    RJH _

      I have what seems a very simple filter, but it is not working the way I expect.

       

      (POSTACCTNO <> "020001001000" .Or.

      POSTACCTNO <> "020301030000") .And.

      ACCTSITE = "02"

       

      I assume that any of the values listed above in the POSTACCTNO field will not show  and any values of "02" for ACCTSITE will show excluding the POSTACCTNO vlaues.

       

      What I see is ACCTSITE with "02" including the POSTACCTNO values listed above. If I only have one POSTACCTNO value and the ACCTSITE value, all records with ACCTSITE of "02" show and the POSTACCTNO values removed.

       

      What am I doing wrong?

        • Filter, compound expressions
          Data Kruncher

          You're really close.

           

          The problem is the .OR. operator, or more explicitly, in how Monarch evaluates boolean expressions.

           

          Since "020001001000" is not equal to "020301030000", the second part of the .OR will evaluate to TRUE, so the record will be included in the results. You could change the .OR. to .AND. to get the results you're after, or use the easier to read (my opinion):

           

          [font="courier"](POSTACCTNO  .NotIn.("020001001000","020301030000")) .And.

          ACCTSITE = "02"   /font[/quote]Does that help?

           

          Kruncher

          • Filter, compound expressions
            Grant Perkins

            Neat Krunching!

             

            Another way to approach the composition of any potentially confusing filter needs is to create each filter component separately -  so here you would build you filter for just

             

            <> "020001001000"

            <> "020301030000"

            and

            ACCTSITE = "02"

             

            and then let Monarch help with making it easy to see the effects of changing the .AND. and .OR.  operators and possibly also the .NOT. operator by using the Compound Filter concept to put them all together.

             

            HTH.

             

            Grant