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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
lavanya14
Contributor III
Contributor III

Urgent Help plz - For loop


Hi All,

I have a table called equipment and i need one more date column through loop lets say

ColumnA     ColumnB     ColumnC            NewDateColumn    

           1             a                      1234             3-Apr-2014

           2              b                      5678             3-Apr-2014

          3               c                      9876             3-Apr-2014

           1             a                      1234            4- Apr-2014

           2              b                      5678             4- Apr-2014

           3              c                      9876              4- Apr-2014

            1             a                      1234            5- Apr-2014

           2              b                      5678             5- Apr-2014

            3              c                     9876                5- Apr-2014

Basically I should have 3 days of date generated for the entire data available in my Table. Lets say for entire data available  in the table it should have 3-Apr-2014 and similarly the available data in table should have 4-Apr-2014.Same follows for 5-Apr-2014.

Any help would be appreciated.

Thanks in advance.

14 Replies
crusader_
Partner - Specialist
Partner - Specialist

Lavanya,

Try in FOR statement convert your variables into NUM

Andrei

Not applicable

Hi,

Try this

 

Load * Inline [
ColumnA, ColumnB, ColumnC
1, a, 1234
2 , b, 5678
3, c, 9876
1, a, 1234
2, b, 5678
3, c, 9876
1, a, 1234
2, b, 5678
3, c, 9876
]
;
Let vColumnA = FieldValueCount('ColumnA');
For A = 1 to $(vColumnA)
Let vNewDateColumn = $(A)+2&'-Apr-2014';
For i = 1 to $(vColumnA)
LoopTest1:
Load

*,
'$(vNewDateColumn)'
as NewDateColumn
Resident LoopTest;
Next;
Next;
Drop Table LoopTest;

tresesco
MVP
MVP

Ahh, I missed the actual issue, it is not about format but the loop variable.

Try:

For i = 0 to  (vMax_Equ -vMin_Equ -1 )

Or,

For i = 0 to  ($(vMax_Equ) - $(vMin_Equ) -1)

flipside
Partner - Specialist II
Partner - Specialist II

Of course, just replace the inline table with ...

load date(today()+rowno()-1) as NewDate autogenerate 5;

flipside

lavanya14
Contributor III
Contributor III
Author

Hi ,

Thats a great help !! Thank you !!