Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
DiegoF
Creator
Creator

How to compare 2 tables with similar values

Hello Qlik professionals!

I have these 2 simple tables that have 3 columns: Name, size (in bytes) and date and time:

DiegoF_0-1714642728371.png

What script can I use to compare both tables, and get a table where I get the rows that have different values?

Thanks!

 

 

Labels (5)
2 Replies
steeefan
Luminary
Luminary

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;

 

 

BrunPierre
Partner - Master
Partner - Master

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;