Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
prees959
Creator II
Creator II

Comparing Yesterday's Orders to Today's

Hi,

Each day we receive an new Orders Dataset :

Yesterdays:

   

Order IDShipped ByStatus
102/02/2018Processed
206/01/2018In Progress
302/02/2018In Progress
402/02/2018In Progress
505/01/2018In Progress
605/01/2018Processed
705/01/2018Processed
805/01/2018Processed
928/12/2017Cancelled
1017/01/2018Processed

Todays:

   

Order IDShipped ByStatus
102/02/2018Processed
206/01/2018Processed
302/02/2018In Progress
402/02/2018Processed
505/01/2018Processed
605/01/2018Processed
705/01/2018Processed
805/01/2018In Progress
1017/01/2018Processed
1122/01/2018Processed

Required Outcome (Latest New Processed Orders)

   

Order IDShipped ByStatus
206/01/2018Processed
402/02/2018Processed
505/01/2018Processed
1122/01/2018Processed

I need to link the latest Processed Orders to a Details Database which takes hours to run as I am running it on 'Today's' dataset as a whole to ensure I have the most upto date 'Processed Order IDs'  It would be great if I could compare the two tables and end up with a 'Final' table where I only need to run the 'Details'  section for 'Today's' new Processed records - and append the new Order Details to to yesterdays order details file.

I've tried using a 'where not exists' on Order ID but it is is bringing all records through as opposed to just the new records. Also, as the Status can change back and forth due to amendments (eg see Order 😎 - is causing me some confusion.....

Also, is it possible to create a second table for those records that were 'Processed' in yesterdays file - but now have a different Status today eg Order 8 or not it the new dataset at all?

If anyone can share any advice - that would be great.

Many thanks,

Phil

1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi Phil,

You'll need to create a Key which uses the OrderID and the Status in order to get updated status records.

Code below, example attached;

Yesterday:

Load *, OrderID &'-'& Status as Key;

LOAD OrderID,

     [Shipped By],

     Status

FROM

data.xlsx

(ooxml, embedded labels, table is Yesterday);

NoConcatenate

Today:

LOAD OrderID,

     [Shipped By],

     Status

FROM

data.xlsx

(ooxml, embedded labels, table is Today)

Where Not Exists(Key, OrderID &'-'& Status)

and Status = 'Processed';

Drop Table Yesterday;

View solution in original post

4 Replies
Anonymous
Not applicable

Hi Phil,

You'll need to create a Key which uses the OrderID and the Status in order to get updated status records.

Code below, example attached;

Yesterday:

Load *, OrderID &'-'& Status as Key;

LOAD OrderID,

     [Shipped By],

     Status

FROM

data.xlsx

(ooxml, embedded labels, table is Yesterday);

NoConcatenate

Today:

LOAD OrderID,

     [Shipped By],

     Status

FROM

data.xlsx

(ooxml, embedded labels, table is Today)

Where Not Exists(Key, OrderID &'-'& Status)

and Status = 'Processed';

Drop Table Yesterday;

Anil_Babu_Samineni

May be try this? I created Flag like Todays and Yesterday

If(Only({<Flag = {'Todays'}>} Status) = Only({<Flag = {'Yesterdays'}>} Status), Status)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
prees959
Creator II
Creator II
Author

Thanks!! Worked Perfectly.

If I wanted to to it the other way around and find out which records exist in 'yesterdays' and not in 'Todays' - is there a similar solution?

Many thanks again.

Phil

Anonymous
Not applicable

No problem,

If you wanted it to work the other way simply switch the load around so Today's data is loaded 1st and Yesterdays 2nd;

Today:

Load *, OrderID &'-'& Status as Key;

LOAD OrderID,

     [Shipped By],

     Status

FROM

data.xlsx

(ooxml, embedded labels, table is Today);

NoConcatenate

Yesterday:

LOAD OrderID,

     [Shipped By],

     Status

FROM

data.xlsx

(ooxml, embedded labels, table is Yesterday)

Where Not Exists(Key, OrderID &'-'& Status)

and Status = 'Processed';

Drop Table Today;