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

Load latest Jobcode field value

Hi All,

i am trying to create a table chart with following fields 

Branch_code, job_start_date, Jobcode

iam able to achieve latest job_start_date with using below script

Temp_tab1:
LOAD 
    Branch_code,
    job_start_date,
    Jobcode
From Tab.qvd;
 
 
NoConcatenate
Final:
Load
        Branch_code,
     Max(job_start_date) as Job_Start_Date
Resident Temp_tab1
Group by Branch_code;
 
above script is working fine as iam getting latest Job_Start_Date
 
i have another field Jobcode need to retrieve latest jobcode
 
in Final table added the Jobcode field and mention same in Group by clause also
 
after adding the Jobcode field in Table chart it is not showing latest jobcode
 
can you suggest how to achieve this
 
Thank you in advance
Eshwar
 

 

Labels (4)
1 Solution

Accepted Solutions
HirisH_V7
Master
Master

 

Data:
Load * inline [
Branch_code, Job_Start_Date, Jobcode
116, 5/27/2024, ocd
116, 4/20/2024, bcs
116, 4/15/2024, hkj
];

Map_Final:
Mapping Load
Branch_code&'|'&
Date(Max(Date#(Job_Start_Date,'MM/DD/YYYY'))) as Key,
1 as 1
Resident Data
Group by Branch_code;

NoConcatenate
Final:
Load * Resident Data Where Applymap('Map_Final',Branch_code&'|'&Date(Date#(Job_Start_Date,'MM/DD/YYYY')))=1;

DROP Table Data;

 

HirisH
“Aspire to Inspire before we Expire!”

View solution in original post

10 Replies
HirisH_V7
Master
Master

Do you need Lastest Date for both Job Code and Branch Code seperately? if so need to call individual group by and create two seperate tables for same. 

Else, do explain with sample data and required output.

 

HirisH
“Aspire to Inspire before we Expire!”
Eshwar1
Contributor III
Contributor III
Author

Thank you for response Hirish

Out Put table like Branch_code, Latest_Job_Start_Date, Latest_Jobcode

1 branch_code have multiple dates and jobcodes

from that i need to display latest date and jobcode

Sample data

Load * inline

 

Branch_code, Job_Start_Date, Jobcode

116,  5/27/2024, ocd

116,  4/20/2024, bcs

116, 4/15/2024, hkj

];

i need to display in table only 116,  5/27/2024, ocd

can u suggest how to achieve.

HirisH_V7
Master
Master

Final:
Load Job_Code,
        Branch_code,
     Max(job_start_date) as Job_Start_Date
Resident Temp_tab1
Group by Branch_code,Job_Code;
 
HirisH
“Aspire to Inspire before we Expire!”
Eshwar1
Contributor III
Contributor III
Author

tried this code but not showing latest Jobcode

latest date is showing but after adding the jobcode in table its not showing latest jobcode

HirisH_V7
Master
Master

As data contains three job code for same branch, when we do groupby it will give output of three lines. Could you elaborate more on why jobcode HKJ to be considered.

HirisH
“Aspire to Inspire before we Expire!”
Digvijay_Singh

Try firstsortedvalue like below if it suits to your situation..

1.Measure 1 - FirstSortedValue(Job_Start_Date,-Job_Start_Date)

2. Measure 2 - firstsortedvalue(Branch_code,-Job_Start_Date)

3. Measure 3 - firstsortedvalue(Jobcode,-Job_Start_Date)

 

Digvijay_Singh_0-1719230470218.png

 

 

HirisH_V7
Master
Master

 

Data:
Load * inline [
Branch_code, Job_Start_Date, Jobcode
116, 5/27/2024, ocd
116, 4/20/2024, bcs
116, 4/15/2024, hkj
];

Map_Final:
Mapping Load
Branch_code&'|'&
Date(Max(Date#(Job_Start_Date,'MM/DD/YYYY'))) as Key,
1 as 1
Resident Data
Group by Branch_code;

NoConcatenate
Final:
Load * Resident Data Where Applymap('Map_Final',Branch_code&'|'&Date(Date#(Job_Start_Date,'MM/DD/YYYY')))=1;

DROP Table Data;

 

HirisH
“Aspire to Inspire before we Expire!”
Eshwar1
Contributor III
Contributor III
Author

same script showing error while loading in my app

below is the error 

Eshwar1_0-1719234147955.png

 

 

Note : above inline table load script is working

HirisH_V7
Master
Master

Pl refer my code, in where statement there is no max.

HirisH
“Aspire to Inspire before we Expire!”