Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Announcing the newest addition to the Qlik Community, Qlik Gallery! Learn More
Partner
Partner

Add calculated field from previous field in loading script

Hi guys,

I have a table like this :

 

TransactionCreditDebit
110000
2010
3010
4010
5510
6010

And I'd like to create another column to get a "closed account balance" field. It has to be like this :

  

TransactionCreditDebitNewDesiredColum
1100001000
2010990
3010980
4010970
5510965
6010955

How could I get it?

Regards, Marcel.

Tags (1)
1 Solution

Accepted Solutions
vamsee
Valued Contributor

Re: Add calculated field from previous field in loading script

Your Credit and Debit fields were not being treated as Numbers.

Added the following code and it worked.

LOAD Transaction,
NUM#(Credit, '######') as Credit,
NUM#(Debit,'#######') as Debit ;

PFA.

6 Replies
vamsee
Valued Contributor

Re: Add calculated field from previous field in loading script

Try

LOAD  *,
ALT(Credit,0) + ALT(Peek(New_Desired_Column),0) - ALT(Debit,0) as New_Desired_Column;

vamsee
Valued Contributor

Re: Add calculated field from previous field in loading script

ALT() is just to make sure it has a numeric value. If the source data does not have nulls then ALT() can be avoided.

Partner
Partner

Re: Add calculated field from previous field in loading script

Thanks vamsee for the try.

I'm trying to do it, but it hasn't worked.

Here's attached the example following your instructions.

vamsee
Valued Contributor

Re: Add calculated field from previous field in loading script

Your Credit and Debit fields were not being treated as Numbers.

Added the following code and it worked.

LOAD Transaction,
NUM#(Credit, '######') as Credit,
NUM#(Debit,'#######') as Debit ;

PFA.

Partner
Partner

Re: Add calculated field from previous field in loading script

Thanks a lot Vamsee!

Regards, Marcel.

vamsee
Valued Contributor

Re: Add calculated field from previous field in loading script

Glad, it worked for you.