3 Replies Latest reply on Apr 28, 2021 8:48 AM by Nico Heinze

    syntax error in my expression

    Thomas Kennedy Seasoned Veteran

      I wrote this expression:

      IIF(Program_Code = '3GBA242AMBA', AND (Concentration_Code_1 = 'R098' OR Concentration_Code_2 = 'R098'), Decode(Attribute_Codes, '3M07', 'Paris Island'))

      but I get a syntax error. I've gone through it a bunch but cannot find where I went wrong. Can anyone point out my mistake?

       

      Thank you,

      Tom

        • 1. Re: syntax error in my expression
          Nico Heinze Guru

          Remove the comma after the first comparison (before the first AND).

           

          BTW this is a perfect example of how I would NEVER build an expression term. No "else" case in both the IIF and the DECODE function. Bad style in my opinion.

          What exactly do you want to achieve? Please explain in plain text.

           

          Regards,

          Nico

          1 of 1 people found this helpful
          • 2. Re: syntax error in my expression
            Thomas Kennedy Seasoned Veteran

            Thank you very much Nico for your correct response. As you've recognized I am not an expression writer but I need this one to only allow the Attribute_Code '3M07' to be added to the PMBA Location field if concentration code 1 or 2 equaled R098 and the Program_Code = 3GBA242AMBA. I also need the '3M07' code translated to text value 'Paris Island' is everything else is equal to true.

            • 3. Re: syntax error in my expression
              Nico Heinze Guru

              As a general hint, I would always use IIF() and DECODE() like in these examples:

               

              IIF( condition, then_values, else_value)

              DECODE( portname, value1, result1, value2, result2, ... (more pairs), default_value)

               

              Makes life simpler in case you have to extend the IIF() or DECODE() function.

               

              If there is no "different" else_value, just enter the port name that you need without any changes. That's good. This way everyone can see that the respective port is used without any changes, assuming the condition is not fulfilled.

               

              I'm happy to hear that it now works as supposed.

               

              Cheers and all the best,

              Nico