Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Loop

I have a table incident_details,

and assigned group a field in it.

I am creating a qvd for open cases, but each should be according to assigned group.

Example,  Suppose Assigned group has 5 data values as A,B,C,D,E,

therefore I want to create open case qvds as Open_A.qvd,Open_B.qvd using a for loop.

Please guide me a bit regarding this....

3 Replies
swuehl
MVP
MVP

Maybe like

FOR Each Group in 'A','B','C','D','E'

Tmp:

LOAD CaseField1, CaseField2

FROM Table WHERE GroupField = '$(Group)';

Store Tmp into Open_$(Group).qvd (qvd);

drop table Tmp;

NEXT

Michiel_QV_Fan
Specialist
Specialist

Try this syntax:

for each group  in 'A','B','C',etc

group_$(group):

load *

from <your location>

where group = $(group);

store group_$(group) into group_$(group).qvd (qvd);

drop table group_$(group);

next

This will loop through all values in the for each ......

Sokkorn
Master
Master

Hi Nitin,

Here concept with example

[Data]:

LOAD * Inline [

ID, AssGrp, Field1

1, A, F1

2, A, F2

3, B, F3];

[tmpCon]:

LOAD Concat(DISTINCT Chr(39)&[AssGrp]&Chr(39),',') As [AssGrpVal] Resident [Data];

Let vAllAssGrp = Peek('AssGrpVal',0,'AssGrp');

DROP Table [tmpCon];

FOR Each vAssGrp in $(vAllAssGrp)

  $(vAssGrp):

  NoConcatenate

  LOAD * Resident [Data] Where [AssGrp]='$(vAssGrp)';

  STORE $(vAssGrp) into [Open_$(vAssGrp).qvd];

  DROP Table $(vAssGrp);

NEXT vAssGrp;

DROP Table [Data];

Let vAllAssGrp = Null();

Let vAssGrp = Null();

Regards,

Sokkorn