Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
marcel_olmo
Partner Ambassador
Partner Ambassador

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.

1 Solution

Accepted Solutions
vamsee
Specialist
Specialist

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.

View solution in original post

6 Replies
vamsee
Specialist
Specialist

Try

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

vamsee
Specialist
Specialist

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

marcel_olmo
Partner Ambassador
Partner Ambassador
Author

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

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.

marcel_olmo
Partner Ambassador
Partner Ambassador
Author

Thanks a lot Vamsee!

Regards, Marcel.

vamsee
Specialist
Specialist

Glad, it worked for you.