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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

looping in qlikview

Hi All,

I have to loop through records.

My requiremnet is

i have to take balance amt from currenct date

and decrement date until required todate and calculate balance for each date until todate.

from date will be current date.

to calculate i have planned for this lgic dnt knw how to implement in qlikview need to display in chart balance for all dates.we only have data for currennt date balance remaining we neeed to calculate.

logic:

initially v_currentdate will be current date(from date) and v_Todate is to date

v_currentdate=

v_Newdate=v_currentdate-1

v_newbalance =balance of v_currentdate-net balance of v_currentdate

v_Newdate=v_Todate (if yes exit else)

v_currentdate=v_Newdate

can anyone help me n using this in qlikview

Regrads,

Prajna

13 Replies
Not applicable
Author


can any one suggest possible solution... is this possible?

Regards,

prajna

vijetas42
Specialist
Specialist

Hi,

can you more elaborate your requirement with example

Not applicable
Author

Hi,

I have balance table with na\balance amt=500

this amt will be for current date - 22 apr

now i need to find balance w.r.t 1 st apr

then

i need to need to iterate from current date to 19th april

i have transaction table where i have net balance with date now i need to sub balancve from balance table with net balance of transaction table.

balance table:

balance amt

200

Transaction table:

Date   net balance

21apr  100

20 apr   200

18 apr     -100

showcase like below

22 apr-  200                Balance

21 apr      200-0=      20(total balance -net balance on 22 apr)

20 apr     200-100=     100

19 apr      100-200=     -100

18 apr      -100-0=     -100

so i can tell... on 18th by balance was -100

on 19th no transaction so blace remain same -100

on 20th 200 rs got credited so now balance is -100=200=100

on 21 apr 100 got credited so balance is 100+100=200

on 22 ap no transaction balance is 200

whenever i need to compute i should go from current date

Regards,

Prajna

Not applicable
Author

Hi Prajna, hope it can help you.

Balance:

LOAD

*

INLINE

[Balance Amt

200

];

Transaction:

LOAD

*

INLINE

[

Date1,Net balance

2014-04-21,100

2014-04-20,200

2014-04-18,-100

];

LET vBalanceAmt = Peek('Balance Amt',0,'Balance');

LET vCurrentDate = NUm(Date#(Date(Now(),'YYYY-MM-DD'),'YYYY-MM-DD'))+1;

Let vNumberOfRows = NoOfRows('Transaction');

Let vNetbalance = 0;

  For vI = 0 to $(vNumberOfRows) - 1

  Let vDate = num(Date#(Peek('Date1',vI,'Transaction'),'YYYY-MM-DD'));

  Let vNetbalance = Peek('Net balance',vI,'Transaction');

  TRACE $(vCurrentDate),$(vDate);

  Result:

  LOAD

  Date($(vCurrentDate)-RecNo(), 'YYYY-MM-DD') AS Date2,

  $(vBalanceAmt)-if($(vCurrentDate)-RecNo()+1 = $(vDate),$(vNetbalance),0) AS Balance

  AutoGenerate($(vCurrentDate)-$(vDate))

  ;

  LET vBalanceAmt = $(vBalanceAmt)-$(vNetbalance);

  LET vCurrentDate = $(vDate);

  next

Not applicable
Author

errorqlik.PNG.png

em getting this error..

Regards,

Prajna

Not applicable
Author

seems you modified some place. looks like your vDate is not correct.

Not applicable
Author

getting this error after modification

errorqlik2.PNG.png

Regards,

Prajan

Not applicable
Author

is that possible to get your sample qvw?

BTW, I noticed that seems 41670 - 41673 make you wrong.

Not applicable
Author

HI,

Suggest solution asap

Thank you

Regards,

Prajna