Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Qlik professionals!
I have these 2 simple tables that have 3 columns: Name, size (in bytes) and date and time:
What script can I use to compare both tables, and get a table where I get the rows that have different values?
Thanks!
The following script loads the data from two QVD files, joins them together on Nombre and performs comparisons on the two other fields:
Comparison_stg1:
NOCONCATENATE LOAD
[Nombre-144] AS Nombre,
[Tamaño (Bytes)-144] AS Bytes144,
[Fecha de modificación-144] AS Date144
FROM
[SAMCA-NT-144.qvd]
(qvd);
LEFT JOIN (Comparison_stg1) LOAD
[Nombre-184] AS Nombre,
[Tamaño (Bytes)-184] AS Bytes184,
[Fecha de modificación-184] AS Date184
FROM
[SAMCA-NT-184.qvd]
(qvd);
Comparison:
NOCONCATENATE LOAD
Nombre,
Bytes144 <> Bytes184 AS isBytesDiff,
Date144 <> Date184 AS isDateDiff
RESIDENT
Comparison_stg1;
DROP TABLE Comparison_stg1;
Hi, perhaps something like this.
/*-------------Create a lookup key for similar records------------------*/
LKeyTemp:
LOAD Hash128("Name","Size","Timestamp") as %LKey FROM T1;
Inner Join
LOAD Hash128("Name","Size","Timestamp") as %LKey FROM T2;
/*-------------Merge the two table------------------*/
Merger:
LOAD LOAD Hash128("Name","Size","Timestamp") as %Key,
*
FROM T1;
LOAD LOAD Hash128("Name","Size","Timestamp") as %Key,
*
FROM T2;
/*-------------Apply filter on the resulting table------------------*/
NoConcatenate
Difference:
LOAD * Resident Merger
Where not Exists(%LKey,%Key);
DROP Tables %LKeyTemp, Merger;
DROP Field %Key;