Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator II
Creator II

Variable for Where Clause and QVD Storage

Currently using Qlik Sense April 2020 Enterprise. I am looking to use a variable to restrict the data and create multiple QVD files.I would like to run some sort of a While loop which will run until all  the variable values are used and QVD's created for each variable value.

For example

$(Variable) =A,B,C ........

Data_Table:

Select *

From Table 

Were Field =$(variable)

Store  Data_Table into \\Serve1\$(variable)\Data_Table.qvd

1 Solution

Accepted Solutions
Highlighted
Partner
Partner

Re: Variable for Where Clause and QVD Storage

Set vVariable = 'A', 'B', 'C' ;

For each v in $(vVariable)

   Data_Table:

   Select *

   From Table 

   Were Field ='$(v)' 

   Store Data_Table into \\Serve1\$(v)\Data_Table.qvd;

   Drop table Data_Table;

Next v

Plees ekskuse my Swenglish and or Norweglish spelling misstakes

View solution in original post

5 Replies
Highlighted
Partner
Partner

Re: Variable for Where Clause and QVD Storage

Set vVariable = 'A', 'B', 'C' ;

For each v in $(vVariable)

   Data_Table:

   Select *

   From Table 

   Were Field ='$(v)' 

   Store Data_Table into \\Serve1\$(v)\Data_Table.qvd;

   Drop table Data_Table;

Next v

Plees ekskuse my Swenglish and or Norweglish spelling misstakes

View solution in original post

Highlighted
Creator II
Creator II

Re: Variable for Where Clause and QVD Storage

Thanx for the solution. I have one more requirement to add.  Once this loadd is done . I am dropping the table but still would like to get the row count for each v. I tried the below statement but it didnt work. Any Ideas?

Data_Table:

   Select *

   From Table 

   Were Field ='$(v)' 

Let vRowCount_Data_Table_$(v) =NoofRows('Data_Table_$(v)')

   Store Data_Table into \\Serve1\$(v)\Data_Table.qvd;

   Drop table Data_Table;

Next v

Highlighted
Partner
Partner

Re: Variable for Where Clause and QVD Storage

You don't have tables named 'Data_Table_$(v)' your table name is 'Data_Table'.

Try this:

Set vVariable = 'A', 'B', 'C' ;

For each v in $(vVariable)

   Data_Table:

   Select *

   From Table 

   Were Field ='$(v)' 

 Let vNoOfRows_$(v) = NoOfRows('Data_Table') ;

 Store Data_Table into \\Serve1\$(v)\Data_Table.qvd;

   Drop table Data_Table;

Next v

Plees ekskuse my Swenglish and or Norweglish spelling misstakes
Highlighted
Creator II
Creator II

Re: Variable for Where Clause and QVD Storage

Thanks for the Prompt responses . ONe last requirement. I would like to create a table for Row count for every single $(v) value. Something like  below which I can create as a Table on Front end.

How I can do that .

Load 

A, 200,900

B, 400,900

etc.  

Highlighted
Partner
Partner

Re: Variable for Where Clause and QVD Storage

Try this:

 

Set vVariable = 'A', 'B', 'C' ;

For each v in $(vVariable)

   Data_Table:

   Select *

   From Table 

   Were Field ='$(v)' 

 

 Let vNoOfRows_$(v) = NoOfRows('Data_Table') ;

   Rowcounts:

   Load

    '$(v)' as Variable,

    NoOfRows('Data_Table') As NoOfRows

   Autogenerate 1;

 Store Data_Table into \\Serve1\$(v)\Data_Table.qvd;

  Drop table Data_Table;

 

Next v

Plees ekskuse my Swenglish and or Norweglish spelling misstakes