2 Replies Latest reply on Jan 25, 2012 4:30 PM by BobSchwenkler

    Grouping logical statements within a function

    BobSchwenkler

      Title

      Grouping logical statements within a function

      Post

      I still haven't figured out the best way, and in some cases, a way at all, to do this. Here's the (non-working) example at hand:Case (not IsEmpty(price)and Left(inventoryID;3) = "DBN" or "IPU";"CD")

       

      What I want here is for Left(inventoryID;3) = "DBN" or "IPU" to evaluate first, then have that result evaluate with not IsEmpty(price)and...


      How do I make this happen?

        • 1. Re: Grouping logical statements within a function
          philmodjunk

          Left(inventoryID;3) = "DBN" or "IPU" is incorrect syntax. It should be written as:

          Left(inventoryID;3) = "DBN" or Left(inventoryID;3) = "IPU"

          And I think you'll want to enclose that in parenthesis to get it to evaluate first to produce this expression:

          (Left(inventoryID;3) = "DBN" or Left(inventoryID;3) = "IPU") and IsEmpty ( Price )

          You could use either patterncount or position to simplify your expression:

          Patterncount ( "DBNIPU" ; Left ( InventoryID ; 3 ) ) And IsEmpty ( Price )

          or:

          Position ( "DBNIPU" ; Left ( InventoryID ; 3 ) ; 1 ; 1 ) And IsEmpty ( Price )

          Patterncount and position will return zero if the left 3 characters of the ID field are neither DBN nor IPU and this evaluates as "False". They'll return a non zero number if it is DBN or IPU and that will evaluate as true.

          • 2. Re: Grouping logical statements within a function
            BobSchwenkler

            Ok, for some reason I thought parentheses didn't work in FM.

             

            Thanks for the simplified examples!