Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Specialist
Specialist

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

View solution in original post

9 Replies
sushil353
Master II
Master II

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

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

Anonymous
Not applicable
Author

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
Partner - Champion III
Partner - Champion III

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
Author

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

Not applicable
Author

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

Not applicable
Author

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

Not applicable
Author

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

Not applicable
Author

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