9 Replies Latest reply: Jul 16, 2015 6:06 AM by Andre Avenant RSS

    Script error: Error in expression:If takes 2-3 parameters

    Andre Avenant

      I get the following error:

      Error in expression:If takes 2-3 parameters....

      Below is the code in the load script. I see the red "(" but cannot get it to work if i add another closing bracket

       

      if("Sale Finalized" = 'Yes', ([L-Idea Commission] * [No Cartons]) + ([L-Margin]*[No Cartons]),
      if("Sale Finalized" = 'No',
      if(("SubSale Deal Type Text"='Consignment') and ("Sale Deal Type Text" = 'Consignment') and (Producer = 'Fruit Pool'), ([FOB?EXW]*0.04),([FOB?EXW] * 0.08),
      if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'Ex Works' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX""L-AdminX" - "Fixed Purchase Price" - ([L-Transport]*[No Cartons])-
      (
      [L-Insurance]*[No Cartons]) - ([L-Marine Insurance]*[No Cartons])),
      if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'CIF' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX""L-AdminX" - "Fixed Purchase Price"),
      if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'FOB' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX""L-AdminX" - "Fixed Purchase Price"),
      if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'DIP' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX""L-AdminX" - "Fixed Purchase Price"),
      if("SubSale Deal Type Text" = 'Consignment' , ([L-Idea Commission] * [No Cartons]) + ([L-Margin]*[No Cartons])))))))) as Profit

       

      Please help!!!

       

       

        • Re: Script error: Error in expression:If takes 2-3 parameters
          Sushil Kumar

          Hi,

           

          Try this:

           

          if("Sale Finalized" = 'Yes', ([L-Idea Commission] * [No Cartons]) + ([L-Margin]*[No Cartons]),

          if("Sale Finalized" = 'No',if(("SubSale Deal Type Text"='Consignment') and ("Sale Deal Type Text" = 'Consignment') and (Producer = 'Fruit Pool'), ([FOB?EXW]*0.04),([FOB?EXW] * 0.08)),

             if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'Ex Works' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX" -  "L-AdminX" - "Fixed Purchase Price" - ([L-Transport]*[No Cartons])-

          ([L-Insurance]*[No Cartons]) - ([L-Marine Insurance]*[No Cartons])),

          if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'CIF' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX" -  "L-AdminX" - "Fixed Purchase Price"),

          if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'FOB' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX" -  "L-AdminX" - "Fixed Purchase Price"),

          if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'DIP' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX" -  "L-AdminX" - "Fixed Purchase Price"),

          if("SubSale Deal Type Text" = 'Consignment' , ([L-Idea Commission] * [No Cartons]) + ([L-Margin]*[No Cartons]))))))))

           

          HTH

          Sushil

          • Re: Script error: Error in expression:If takes 2-3 parameters
            Kalyan Navuluri

            Seems you lost here in your exp, here true and false both evaluating so that the expression ends here, please try to evaluate once you expression

            else post an sample app to look into it with expected outut

             

            if("Sale Finalized" = 'Yes', ([L-Idea Commission] * [No Cartons]) + ([L-Margin]*[No Cartons]),
            if("Sale Finalized" = 'No',
            if(("SubSale Deal Type Text"='Consignment') and ("Sale Deal Type Text" = 'Consignment') and (Producer = 'Fruit Pool'), ([FOB?EXW]*0.04),([FOB?EXW] * 0.08),
            if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'Ex Works' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX""L-AdminX" - "Fixed Purchase Price" - ([L-Transport]*[No Cartons])-
            (
            [L-Insurance]*[No Cartons]) - ([L-Marine Insurance]*[No Cartons])),
            if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'CIF' , ("ExWorks Selling" - "Exworks CostX" -"L-FinanceX""L-AdminX" - "Fixed Purchase Price"),
            if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'FOB' , ("ExWorks Selling" - "Exworks CostX"- "L-FinanceX""L-AdminX" - "Fixed Purchase Price"),
            if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'DIP' , ("ExWorks Selling" - "Exworks CostX"- "L-FinanceX""L-AdminX" - "Fixed Purchase Price"),
            if("SubSale Deal Type Text" = 'Consignment' , ([L-Idea Commission] * [No Cartons]) + ([L-Margin]*[No Cartons])))))))) as Profit

              • Re: Script error: Error in expression:If takes 2-3 parameters
                Andre Avenant

                and it now looks like this:

                 

                if("Sale Finalized" = 'Yes', ([L-Idea Commission] * [No Cartons]) + ([L-Margin]*[No Cartons]),
                if("Sale Finalized" = 'No',
                if(("SubSale Deal Type Text"='Consignment') and ("Sale Deal Type Text" = 'Consignment') and (Producer = 'Fruit Pool'), ([FOB?EXW]*0.04),//([FOB?EXW] * 0.08),
                  if(("SubSale Deal Type Text"='Consignment') and ("Sale Deal Type Text" = 'Consignment') and (Producer <> 'Fruit Pool'), ([FOB?EXW]*0.08),
                if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'Ex Works' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX""L-AdminX" - "Fixed Purchase Price" - ([L-Transport]*[No Cartons])-
                (
                [L-Insurance]*[No Cartons]) - ([L-Marine Insurance]*[No Cartons])),
                if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'CIF' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX""L-AdminX" - "Fixed Purchase Price"),
                if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'FOB' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX""L-AdminX" - "Fixed Purchase Price"),
                if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'DIP' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX""L-AdminX" - "Fixed Purchase Price"),
                if("SubSale Deal Type Text" = 'Consignment' , ([L-Idea Commission] * [No Cartons]) + ([L-Margin]*[No Cartons])))))))))) as Profit

              • Re: Script error: Error in expression:If takes 2-3 parameters
                Bill Markham

                The bit is red below is an if with 4 parameters, which will give the error you are getting.

                 

                 

                 

                if("Sale Finalized" = 'Yes',

                  ([L-Idea Commission] * [No Cartons]) + ([L-Margin]*[No Cartons]),

                if("Sale Finalized" = 'No',

                if( ("SubSale Deal Type Text"='Consignment') and ("Sale Deal Type Text" = 'Consignment') and (Producer = 'Fruit Pool'),

                  ([FOB?EXW]*0.04),

                  ([FOB?EXW] * 0.08),

                if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'Ex Works' ,

                  ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX" -  "L-AdminX" - "Fixed Purchase Price" - ([L-Transport]*[No Cartons])-([L-Insurance]*[No Cartons]) - ([L-Marine Insurance]*[No Cartons])),

                if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'CIF' ,

                  ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX" -  "L-AdminX" - "Fixed Purchase Price"),

                if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'FOB' ,

                  ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX" -  "L-AdminX" - "Fixed Purchase Price"),

                if("SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'DIP' ,

                  ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX" -  "L-AdminX" - "Fixed Purchase Price"),

                if("SubSale Deal Type Text" = 'Consignment' ,

                  ([L-Idea Commission] * [No Cartons]) + ([L-Margin]*[No Cartons]))))))))

                 

                 

                as Profit

                • Re: Script error: Error in expression:If takes 2-3 parameters
                  Alessandro Saccone

                  The mistake begins at the row:

                   

                  if(("SubSale Deal Type Text"='Consignment') and ("Sale Deal Type Text" = 'Consignment') and (Producer = 'Fruit Pool'), ([FOB?EXW]*0.04),([FOB?EXW] * 0.08),
                  if(
                  "SubSale Deal Type Text" = 'Fixed' and "Selling Cost Type" = 'Ex Works' , ("ExWorks Selling" - "Exworks CostX" - "L-FinanceX""L-AdminX" - "Fixed Purchase Price" - ([L-Transport]*[No Cartons])-
                  (
                  [L-Insurance]*[No Cartons]) - ([L-Marine Insurance]*[No Cartons])),

                   

                  the correct syntax is:

                   

                  If(condition, Cond.True,

                        If(condition, Cond.True,

                   

                  cond.false

                        )

                   

                  )