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: 
Sharbel
Contributor III
Contributor III

Load Script

Hello,

I have the following transactions table (Source table):

Sharbel_2-1700299275979.png

I am trying to write load script that achieves the followings: for each Clinet_no, Client_name and Transaction_date the script loads only the  row with the most recent File_Date.

Given the above source table, the desired load script will generate the following table :

Sharbel_3-1700299325130.png

 

Any ideas?

Best regards,

Sharbel

 

Labels (2)
2 Solutions

Accepted Solutions
maheshkuttappa
Creator II
Creator II

This code works based on sample data. What is the size of the data??  

T:
LOAD
File_Date,
Serial_no,
Client_no,
Client_name,
Transaction_date
FROM [lib://DataFiles/Sample.xlsx]
(ooxml, embedded labels, header is 1 lines, table is Sheet1);


T2:
Inner Join (T)
Load
Max(File_Date) as File_Date,
Client_no,
Transaction_date
Resident T Group By Client_no, Client_name,Transaction_date;

View solution in original post

sidhiq91
Specialist II
Specialist II

@Sharbel  Please use the below code to get the desired output.

NoConcatenate
Temp:
Load Date(File_Date,'DD/MM/YYYY') as File_Date,
Serial_no,
Client_no,
Client_name,
Date(Transaction_Date,'DD/MM/YYYY') as Transaction_Date

Inline [
File_Date,Serial_no,Client_no,Client_name,Transaction_Date
18/11/2023,23111600,93600011,Benjamin Carter,18/11/2023
15/11/2023,23111511,93600011,Benjamin Carter,12/11/2023
13/11/2023,23111309,93600011,Benjamin Carter,12/11/2023
12/11/2023,23111208,93600011,Benjamin Carter,12/11/2023
13/11/2023,23111309,39500001,Emma Johnson,08/11/2023
12/11/2023,23111208,39500001,Emma Johnson,08/11/2023
08/11/2023,23111806,39500001,Emma Johnson,08/11/2023
];

NoConcatenate
Temp1:
Load Date(Max(File_Date),'DD/MM/YYYY') as Max_File_Date,
Date(Max(File_Date),'DD/MM/YYYY') & Client_no as Key,
Client_no,
Transaction_Date
Resident Temp
group by Client_no,Transaction_Date;

Inner join (Temp1)
Load Date(File_Date,'DD/MM/YYYY') & Client_no as Key,
Serial_no,
Client_name
Resident Temp;

Drop field Key from Temp1;

Drop table Temp;

Exit Script;

If this resolves your issue, please like and accept it as a solution.

View solution in original post

2 Replies
maheshkuttappa
Creator II
Creator II

This code works based on sample data. What is the size of the data??  

T:
LOAD
File_Date,
Serial_no,
Client_no,
Client_name,
Transaction_date
FROM [lib://DataFiles/Sample.xlsx]
(ooxml, embedded labels, header is 1 lines, table is Sheet1);


T2:
Inner Join (T)
Load
Max(File_Date) as File_Date,
Client_no,
Transaction_date
Resident T Group By Client_no, Client_name,Transaction_date;

sidhiq91
Specialist II
Specialist II

@Sharbel  Please use the below code to get the desired output.

NoConcatenate
Temp:
Load Date(File_Date,'DD/MM/YYYY') as File_Date,
Serial_no,
Client_no,
Client_name,
Date(Transaction_Date,'DD/MM/YYYY') as Transaction_Date

Inline [
File_Date,Serial_no,Client_no,Client_name,Transaction_Date
18/11/2023,23111600,93600011,Benjamin Carter,18/11/2023
15/11/2023,23111511,93600011,Benjamin Carter,12/11/2023
13/11/2023,23111309,93600011,Benjamin Carter,12/11/2023
12/11/2023,23111208,93600011,Benjamin Carter,12/11/2023
13/11/2023,23111309,39500001,Emma Johnson,08/11/2023
12/11/2023,23111208,39500001,Emma Johnson,08/11/2023
08/11/2023,23111806,39500001,Emma Johnson,08/11/2023
];

NoConcatenate
Temp1:
Load Date(Max(File_Date),'DD/MM/YYYY') as Max_File_Date,
Date(Max(File_Date),'DD/MM/YYYY') & Client_no as Key,
Client_no,
Transaction_Date
Resident Temp
group by Client_no,Transaction_Date;

Inner join (Temp1)
Load Date(File_Date,'DD/MM/YYYY') & Client_no as Key,
Serial_no,
Client_name
Resident Temp;

Drop field Key from Temp1;

Drop table Temp;

Exit Script;

If this resolves your issue, please like and accept it as a solution.