Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help to create a field dynamicaly

Hi Everyone,

I have two fields date and blnc

DateBalance
1/04/2014856
2/04/2014147
3/04/2014259
4/04/2014325
8/04/2014693
9/04/2014258

I have to add two new field CurrentAcc and InitialAcc.

initially InitialAcc=0,

and Expression for CurrentAcc=Balance+InitialAcc.

And for next date InitialAcc=CurrentAcc.

I know I have to use a loop statements but how I use the expression in the back end. If anyone has any idea do share with me.

Thank you in advance.

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

Temp:

Load

  RowNo() as NO,

  Date(Date#(Date,'D/MM/YYYY')) as Date,

  Balance

Inline

[

  Date, Balance

  1/04/2014, 856

  2/04/2014, 147

  3/04/2014, 259

  4/04/2014, 325

  8/04/2014, 693

  9/04/2014, 258

];

Final:

Load

  NO,

  Date,

  Balance,

  If(RowNo() = 1, 0, Peek(CurrentAcc)) as InitAcc,

  If(RowNo() = 1, Balance, Peek(CurrentAcc)+Balance) as CurrentAcc

Resident Temp;

Drop Table Temp;

View solution in original post

7 Replies
Not applicable
Author

use the RowNo() and Peek() functions, the examples are quite good it

Not applicable
Author

But how I store the value in the field,do you have any script idea for it. since I am very new to qlikview so I didnt get the right way to do.

MK_QSL
MVP
MVP

Use below script..

===================

Temp:

Load

  RowNo() as NO,

  Date(Date#(Date,'D/MM/YYYY')) as Date,

  Balance

Inline

[

  Date, Balance

  1/04/2014, 856

  2/04/2014, 147

  3/04/2014, 259

  4/04/2014, 325

  8/04/2014, 693

  9/04/2014, 258

];

Final:

Load

  NO,

  Date,

  Balance,

  If(RowNo() = 1, Balance, Peek(CurrentAcc)+Balance) as CurrentAcc

Resident Temp

Order By NO;

Drop Table Temp;

//Drop Field NO

=====================================

selvakumarsr
Creator
Creator

Try this..

RangeSum(Above(Sum(Balance), 0, RowNo()))...

Selva

Not applicable
Author

DateBalanceInitAccCurrAcc
1/04/20148560856
2/04/20141478561003
3/04/201425910031262
4/04/201432512621587
8/04/201469315872280
9/04/201425822802538

This script is not giving the right answer. I want a new table with above field..

MK_QSL
MVP
MVP

Temp:

Load

  RowNo() as NO,

  Date(Date#(Date,'D/MM/YYYY')) as Date,

  Balance

Inline

[

  Date, Balance

  1/04/2014, 856

  2/04/2014, 147

  3/04/2014, 259

  4/04/2014, 325

  8/04/2014, 693

  9/04/2014, 258

];

Final:

Load

  NO,

  Date,

  Balance,

  If(RowNo() = 1, 0, Peek(CurrentAcc)) as InitAcc,

  If(RowNo() = 1, Balance, Peek(CurrentAcc)+Balance) as CurrentAcc

Resident Temp;

Drop Table Temp;

Not applicable
Author

Manish has the answer you are looking for

Temp:

Load

  RowNo() as NO,

  Date(Date#(Date,'D/MM/YYYY')) as Date,

  Balance

Inline

[

  Date, Balance

  1/04/2014, 856

  2/04/2014, 147

  3/04/2014, 259

  4/04/2014, 325

  8/04/2014, 693

  9/04/2014, 258

];

Final:

Load

  NO,

  Date,

  Balance,

  If(RowNo() = 1, 0, Peek(CurrentAcc)) as InitAcc,

  If(RowNo() = 1, Balance, Peek(CurrentAcc)+Balance) as CurrentAcc

Resident Temp;

Drop Table Temp;