Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Conditional load of fields from different QVD files.

Hello,

I have a scenario where I have multiple QVD files.

Say file_Oct_2013, file_Nov_2013 and file_Dec_2014 (..and so on). Each file has exactly same fields. Let us say four fields in each files are field_A, field_B, field_C and field_D. [Let us consider field_A is DATE field]

But files from Jan 2014 onwards (say file_Jan_2014, file_Feb_2014...), have an additional field called field_E, which was not present in earlier files.

Now I have a code that uses a FOR LOOP to go to the qvd location and loads every file using wild-card match:

for each File_Name in filelist('$(v_Qvd_DirPath)\file_*.qvd')

Since the new QVD files have an additional fields hence the above code throws an error.

So, is there anyway of resolving this problem using any QV inbuilt function? (For example: FieldNumber().... but that's not going to work as I loading from QVDs and not from tables).

So, I have decided to split the LOAD on putting a where condition on field_A<= Date '12-31-2013' (which will cause my load script to be divided in two parts almost writing the same code again for field_A > Date '12-31-2013'...this works )...but I am looking for an optimal way of accomplishing this.

Thanks!!

1 Solution

Accepted Solutions
Not applicable
Author

Thank you for your comments. I created if staments inside loop and once it finishes, I concatenate the files.

View solution in original post

5 Replies
tresesco
MVP
MVP

Not sure what you are trying to achieve. Equivalent to FieldNumber(), you can try:

QvdNoOfFields ('C:\MyDir\MyFile.qvd')

Or, may be you need concatenate keyword to forcefully concatenate the tables.

Not applicable
Author

If you do go down the concatenate option, you will need to adjust the loop a bit so that the first cycle creates the table and all others then concatenate.

Not applicable
Author

Hi,

To keep it simple, let me explain my example (as the real-life code is too big to comprehend).

File_1.qvd has 3 data fields A, B, C

File_2.qvd has 4 data fields A, B, C, D

Available Info: Field A is a date field. When A < 7/1/2014 [format: MM/DD/YYYY] the qvd has three fields else 4 fields. Both qvd files are in same location.

I need to loop through the files when I "LOAD" data.

So, is it possible using a single FOR EACH to load data (Number of fields varies depending on the date field A)??

Not applicable
Author

Thank you for your comments. I created if staments inside loop and once it finishes, I concatenate the files.

Not applicable
Author

Good stuff, glad to be of help

Joe