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

Compare headers of two QVD files

Hi all,

I have to compare the headers of two QVD files. For example, if my QVD1 has orderID and Description, I have to check if my another QVD has the same orderID and Description.

Set a = 'C:\Users\admin\Desktop\QlikView Development\Order.qvd';

LET vQvdNoOfFields = QvdNoOfFields(a);

     for i=1 to $(vQvdNoOfFields)

          LET vQvdFieldName = QvdFieldName(a,$(i));

          TRACE QvdFieldName: $(vQvdFieldName);

     NEXT i


I am able to get the headers of a QVD1 in variable vQvdFieldName and for another QVD2 in vQvdFieldName1. How should I compare all the headers of both the QVDs

1 Solution

Accepted Solutions
tresesco
MVP
MVP

You would require two loops one in another, like:

for i=1 to $(vQvdNoOfFields)

          LET vQvdFieldName = QvdFieldName(a,$(i));

              for k=1 to $(vQvdNoOfFields)

                    LET vQvdFieldName2 = QvdFieldName(a,$(k));

                    If vQvdFieldName2=vQvdFieldName Then .......

               NEXT k

     NEXT i

View solution in original post

9 Replies
tresesco
MVP
MVP

You would require two loops one in another, like:

for i=1 to $(vQvdNoOfFields)

          LET vQvdFieldName = QvdFieldName(a,$(i));

              for k=1 to $(vQvdNoOfFields)

                    LET vQvdFieldName2 = QvdFieldName(a,$(k));

                    If vQvdFieldName2=vQvdFieldName Then .......

               NEXT k

     NEXT i

Not applicable
Author

Hi Tresesco,

I am getting an error on 'if' statment

If $(vQvdFieldName2) = $(vQvdFieldName)

                       trace qvd field$(k):$(vQvdFieldName2);

ENDIF

Is there any way to store the field headers in an array variable and later compare it?

tresesco
MVP
MVP

Missing 'then'; Try like:

If $(vQvdFieldName2) = $(vQvdFieldName) Then

                       trace qvd field$(k):$(vQvdFieldName2);

EndIf

Not applicable
Author

Hi Tresesco,

Trace statement inside if statement is not appearing when i debug.

it validates the condition and just skips it. Can you please help me with this?

Set a = 'C:\Users\admin\Desktop\QlikView Development\Order.qvd';

LET vFileSize = FileSize(a);

LET vQvdCreateTime = QvdCreateTime(a);

LET vQvdNoOfRecords = QvdNoOfRecords(a);

LET vQvdNoOfFields = QvdNoOfFields(a);

LET vQvdTableName = QvdTableName(a);

TRACE --;

TRACE FileSize: $(vFileSize);

TRACE QvdNoOfRecords: $(vQvdNoOfRecords);

TRACE QvdNoOfFields: $(vQvdNoOfFields);

TRACE QvdTableName: $(vQvdTableName);

TRACE --;

set b = 'C:\Users\admin\Desktop\Order Validate.qvd';

LET vFileSize1 = FileSize(b);

LET vQvdCreateTime1 = QvdCreateTime(b);

LET vQvdNoOfRecords1 = QvdNoOfRecords(b);

LET vQvdNoOfFields1 = QvdNoOfFields(b);

TRACE --;

TRACE FileSize: $(vFileSize1);

TRACE QvdNoOfRecords: $(vQvdNoOfRecords1);

TRACE QvdNoOfFields: $(vQvdNoOfFields1);

TRACE QvdTableName: $(vQvdTableName1);

TRACE --;

for i=1 to $(vQvdNoOfFields)

          LET vQvdFieldName = QvdFieldName(a,$(i));

              for k=1 to $(vQvdNoOfFields1)

                    LET vQvdFieldName2 = QvdFieldName(a,$(k));

                  If $(vQvdFieldName2) = $(vQvdFieldName) Then

                       trace $(vQvdFieldName2);

                    End If

               NEXT k       

NEXT i

Result :

--

FileSize: 4504

QvdNoOfRecords: 5

QvdNoOfFields: 5

QvdTableName: Incremental

--

--

FileSize: 3717

QvdNoOfRecords: 0

QvdNoOfFields: 5

QvdTableName: Order Validate

--

--- Script Finished ---

tresesco
MVP
MVP

Use sleep command to check the trace output during load. And incorporate an Else part in the condition and check if the condition is being true or false.

If $(vQvdFieldName2) = $(vQvdFieldName) Then

                      trace $(vQvdFieldName2);

                      Sleep 2000;

Else

                     trace 'Entered into Else';

                     Sleep 2000;  

End If

Not applicable
Author

Hi Tresesco,

When I parse it takes an else path even if the fields are same.

For example

the debugger says

if ProductID = ProductID

then

Else trace Fields do not match


Can I know why is this happening?

tresesco
MVP
MVP

That could be because ProductID might not be considered as string. Define your variables with SET rather than Let, and retry.

Not applicable
Author

Hi Tresesco,

Many thanks.

I gave the variable in quotes. And it is working fine.

If '$(vQvdFieldName2)' = '$(vQvdFieldName)' Then

                      trace $(vQvdFieldName2);

                      Sleep 2000;

Thanks a lot

mjayachandran
Creator II
Creator II