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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
ksk278074
Contributor III
Contributor III

For loop in qliksense

Hi experts,

I am having one inline table like below

load * inline [

month,org

april, a

may,b

jun,c

];

now my aim is need to load the month data for each org.

ex: i want april month data for a ,b and c org and alos may month data for a,b and c org like ....

how to write the for loop for the same  please help me on the same?

5 Replies
undergrinder
Specialist II
Specialist II

Hi Siva,

You dodn't need loop for achive this.

base:

load * inline [

month,org

april, a

may,b

jun,c

];


org:

Load org Resident base;


left join(org)

Load month Resident base;


drop table base;

G.

YoussefBelloum
Champion
Champion

Hi,

try this:

table:

load * inline [

month,org

april, a

may,b

jun,c

];

for each month in FieldValueList('month')

LOAD '$(month)' as month, org Resident table;

NEXT month

sunilkumarqv
Specialist II
Specialist II

try this ,also @youfas

table:

load * inline [

month,org

april, a

may,b

jun,c

];

For i = 0 to FieldValueCount('month')

LET vmonth = Peek('month',$(i),table);


LOAD '$(vmonth)' as month, org Resident table;


NEXT i

ksk278074
Contributor III
Contributor III
Author

Thanks,

that is working fine!

If will have many fields in my inline load in that case is it possible to get the data ?

YoussefBelloum
Champion
Champion

you're welcome, if you add another field for example, you will have the same number of lines with the data of that new field,

example, you add another field named test, like this:

table:

load * inline [

month,org,test

april, a, test1

may,b, test2

jun,c, test3

];

you will have this:

aprilatest1
aprilbtest2
aprilctest3
junatest1
junbtest2
junctest3
mayatest1
maybtest2
mayctest3

if yo need something else you need to change the script until you get what you want