Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

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

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!!!

1 Solution

Accepted Solutions
qlikmsg4u
Not applicable

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

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

9 Replies
sushil353
Not applicable

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

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

qlikmsg4u
Not applicable

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

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

bill_markham
Not applicable

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

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

alexandros17
Not applicable

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

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

      )

)

Not applicable

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

That did not work...but I found the problem via te other guys responses...

Not applicable

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

yeah,,,lack of sleep makes you type weird stuff

Not applicable

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

yeah,,,lack of sleep makes you type weird stuff

Not applicable

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

yeah,,,lack of sleep makes you type weird stuff

Not applicable

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

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