Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

erebitis
New Contributor III

Invalid Expression in data load script

Hello All, I dont know why get a error when try Load this Script:

"

Budget:
LOAD DISTINCT
ApplyMap('Mapeo_Hi',AccountAct) As Account,
if (AccountAct ='Ton', sum(ValorActBN), Sum(ValorActBN)*1000 ) AS Valor,
FROM [lib://Hi\0619+\*.xlsx](ooxml, embedded labels,header is 1 lines,table is EERR_Norte)
GROUP BY ApplyMap('Mapeo_Hi',AccountAct),Mid(FileName(),FindOneOf( FileName(), '_')+1, 4) ,Capitalize(Mid(FileName(),1, FindOneOf( FileName(), '_')-1));

"

I get a "Invalid expression" whe try to Load.

I know that the problem is this line:  "if (AccountAct ='Ton', sum(ValorActBN), Sum(ValorActBN)*1000 ) AS Valor, "

If I reemplace it for: " Sum(ValorActBN)*1000 AS Valor," the load is correct, but I need to *1000 all the data except the AccountAct named "Ton"

Any one can Help? Thx for advance.

1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: Invalid Expression in data load script

I believe it should be:

Sum(ValorActBN * if(AccountAct ='Ton', 1, 1000))  AS Valor,

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

4 Replies
MVP & Luminary
MVP & Luminary

Re: Invalid Expression in data load script

I believe it should be:

Sum(ValorActBN * if(AccountAct ='Ton', 1, 1000))  AS Valor,

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

erebitis
New Contributor III

Re: Invalid Expression in data load script

Thanks Rob, Now the load don't show any error, but the expression is not calculated, all AccountAct are in empty in the database. Any idea?

Jorge

MVP & Luminary
MVP & Luminary

Re: Invalid Expression in data load script

Not sure. Can you upload a sample?

erebitis
New Contributor III

Re: Invalid Expression in data load script

Hi Rob, I've had a mistake in my code. You are right the solution works perfect.

Thanks very much!

Regards

Jorge