Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
What should be the code to generate ID
1) starting from 1 to 50
2) starting from 1 to 50 only odd numbers
3) starting from 2 to 50 only even numbers
using loops in QlikView scripts?
I have tried using below method and it's working but need to know any For Next Loop...
Load
RowNo() as ID
AutoGenerate 50;
Let vStart= 0;
Let vEnd = 30;
Let vDIFF = $(vEnd) - $(vStart);
Load
RowNo() as ID
AutoGenerate $(vDIFF);
Not sure what you're asking
load RecNo() as ID1,
if(mod(RecNo(),2),RecNo()) as ID2,
if(mod(RecNo(),2),null(),RecNo()) as ID3
AutoGenerate 50;
load RecNo() as Rec, RecNo()*2 as IDeven
AutoGenerate 25;
load RecNo() as Rec, RecNo()*2-1 as IDodd
AutoGenerate 25;
Manish,
Try this:
Let vStart= 0;
Let vEnd = 30;
Let vDIFF = $(vEnd) - $(vStart);
Load
RowNo() as ID
WHERE even(RowNo())
AutoGenerate $(vDIFF);
for even numbers.
odd() function for odd numbers
And with concatenate ... if you want to add these lines to a previous table.
Fabrice
I have tried all above and working fine but need to know whether we can achieve the same result by
For Next Loops .. something like below VB Code...
I know that your above answer is working but I don't want to use AutoGenerate function...
Please don't ask me why as this is the requirement from someone else...
Sub test()
Dim i As Integer
i = 1
For i = 1 To 10
Debug.Print i
Next i
End Sub
Update : This one is showing error...
You're right. This one will work better (I have tested it, hte other not):
Data:
LOAD ID
where even(ID);
Load IterNo() as ID
Autogenerate 1
while IterNo()<= $(vDIFF);
For a=1 to 30 STEP 2
(your script)
Next
Fabrice
This one will create a sequence of numbers from Start to End with a given step size:
Let vStart = -10;
Let vEnd = 10;
Let vStep = 0.1;
Let vDIFF = ($(vEnd) - $(vStart))/$(vStep);
LOAD
$(vStart)+(Rowno()-1)*$(vStep) as fieldName,
AutoGenerate $(vDIFF);
To get a series of odd or even values, you would set vStep = 2 and make sure the start value is Odd or Even,depending on what you're looking for.