Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Sai33
Partner - Creator
Partner - Creator

Loop Through Field and get Next

Hello All,

I have a QVD with the following example data

PartInfo
2019091812
2019091813
2019091814

 

Here, i've an Select Statement where i would like to pass the PartInfo column from the above table as a Where Variable for Where Condition. 

For Each PartInfo in FieldValueList('PartInfo')

[Source_Data]:

Select *

From Table A

Where PartInfo='$(PartInfo)';

Store [Source_Data] into Source_Data_$(PartInfo);

Next PartInfo

 

But, i'm not able to completely get through the complete Table. My script generates the QVD file for the first value and then i get a error.

Can you please suggest how to let the loop run the select Statement through all the 'PartInfo' values.

 

Thanks

Sai.

Labels (2)
1 Solution

Accepted Solutions
andoryuu
Creator III
Creator III

I have executed the load script above in Qlik Sense September 2019 Patch 2 without issue.  Example attached.  If you're having trouble fitting it to your QVF you can attach it and I'll take a look.  Please note that "QVD Dimensions" is the name of a folder typed data connection I have for QVD files.

View solution in original post

5 Replies
andoryuu
Creator III
Creator III

You don't say where TableA is coming from so the below assumes its a table that is already loaded. If this is supposed to be a SQL statement from a database to which you area already connected then you need to have a LOAD * SQL beore your Select. You have various parts that you need to fix that I've shown below. You need to prevent Source_Data from being concatenated, you need to drop it after each write-out to QVD, you need to identify the file as a QVD, and you need the QVD extension.


TextTest:
LOAD * INLINE [
PartInfo
string
string
string
string
straw
straw
straw
];


NoConcatenate
ValuesToSearch:
LOAD * INLINE [
PartInfo
string
straw
];

For Each PartInfo in FieldValueList('PartInfo')

NoConcatenate
[Source_Data]:
LOAD *
Resident TextTest
Where PartInfo='$(PartInfo)';

Store [Source_Data] into [lib://QVD Dimensions/Source_Data_$(PartInfo).qvd](qvd);

Drop table [Source_Data];

Next PartInfo
Sai33
Partner - Creator
Partner - Creator
Author

Thanks for the quick suggestion!

For Each PartInfo in FieldValueList('PartInfo') - At this point i get an Error saying Field string (From your Example Data) not found.

andoryuu
Creator III
Creator III

I have executed the load script above in Qlik Sense September 2019 Patch 2 without issue.  Example attached.  If you're having trouble fitting it to your QVF you can attach it and I'll take a look.  Please note that "QVD Dimensions" is the name of a folder typed data connection I have for QVD files.

Sai33
Partner - Creator
Partner - Creator
Author

Thanks again. You saved my day!

My mistake was i had the Next before the Drop Statement.

andoryuu
Creator III
Creator III

I'm glad it all worked out!