Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
BI & Data Trends 2021. Discover the top 10 trends emerging in today. Join us on Dec. 8th REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Partner
Partner

Put all the values of a field into a variable (loop maybe?)

Hi guys, stalwar1

Suppose I have a table containg a field Alert:

load Alert inline [

Alert

alert1

alert2

alert3

];

How to do to store all of the alerts (alert1, alert2 and alert3) into a variable?

the goal is to store all this values ito a database as a final objectif; for this, I want to be able to loop all the alerts one by one, and everytime store one value into the destination column, till all the values are stored.

Hope my question is clear enough?

1 Solution

Accepted Solutions
Highlighted
Partner
Partner

Try it like this Sunny ! It works !

alerts:

load Alert inline [

Alert

alert1

alert2

alert3

];

FOR Each a in FieldValueList('Alert')

dim:

let vAlert = a;

LOAD '$(vAlert)'  as Alerts AutoGenerate 1;

Store dim into [lib://OBS/class.txt] (txt);

NEXT a

View solution in original post

17 Replies
Highlighted

May be like this

load Alert inline [

Alert

alert1

alert2

alert3

];

For i = 1 to FieldValueCount('Alert')

     LET vAlert$(i) = FieldValue('Alert', $(i));

NEXT i;

Highlighted
Partner
Partner

what to do to store it in a txt file for example?

when I exactly copy your script and then do as follow, I have this answer

Table: 

LOAD $(vAlert$(i)) as [Variable Value] 

AutoGenerate 1; 

 

STORE [Variable Value] FROM Table INTO [lib://OBS/class.txt]

(txt);

Capture.PNG

Highlighted

You can store a table, not a variable value... what exactly are you trying to do?

Highlighted
Partner
Partner

I want to be able to store alerts from qlik sense into a database table ; I'm inspired by this:

Capture.PNG

so what I'm trying to do, is to store all the values (all the alerts) into the variable, and then call the procedure to each time store an alert.

I see that he's using a variable vCompany, that's why I thought about using variables.

Hope this was clear..

Highlighted
Partner
Partner

And ps:

I see here that It's possible to store a variable into a table:

Capture.PNG

Highlighted

This is out of my league Omar...  I won't be able to help you with this brother

Highlighted
Partner
Partner

when I tried this:

alerts:

load Alert inline [

Alert

alert1

alert2

alert3

];

For i = 1 to FieldValueCount('Alert')

     LET vAlert  = FieldValue('Alert', $(i));

Table: 

//LOAD $(vAlert) as [Variable Value] AutoGenerate 1 ;

load FieldValue('Alert', $(i)) as alert resident alerts; 

STORE  alert FROM Table INTO [lib://OBS/class.txt]

(txt);

NEXT i;

each alert is stored 3 times; (problem with the loop logic)

but when I try it with variable instead; I have this:

Capture.PNG

Highlighted
Creator III
Creator III

Try -> Concat(FieldName, ',')          as FieldNameList

Highlighted

You can store a variable into a table, but you can store a table into a txt file like this

Table:

LOAD $(vAlert$(i)) as [Variable Value]

AutoGenerate 1;

STORE Table FROM Table INTO [lib://OBS/class.txt]

(txt);

But this is not possible

Table:

LOAD $(vAlert$(i)) as [Variable Value]

AutoGenerate 1;

STORE [Variable Value] FROM Table INTO [lib://OBS/class.txt]

(txt);