Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good morning all,
Need your help getting the maxdate from a employee table. What I have is multiple entries for the same employee with different WEDAT's. I only need my file to contain the most current WEDAT record. How can I achieve this? I would like to do it in my load script.
Thanks
[As of Date] AS [WEDAT],
[Cost Ctr] AS [Profit Center],
[Emp #] AS [All.Emp #],
[Activity] AS [JobCode],
[Emp Subgrp] AS [All.Emp Subgrp],
[Date 2] AS [All.Date 2],
[As of Date] & [Cost Ctr] & [Emp #] & [Activity] & [Emp Subgrp] & [Date 2] as ConKey
u shud only have 2 tables in ur data model then....Tab1 & Tab3 linked by [All.Emp #].
HI
Try like this
Test:
Load
[As of Date] AS WEDAT,
[Cost Ctr] AS [Profit Center],
[Emp #] AS [All.Emp #],
[Activity] AS [JobCode],
[Emp Subgrp] AS [All.Emp Subgrp],
[Date 2] AS [All.Date 2],
[As of Date] & [Cost Ctr] & [Emp #] & [Activity] & [Emp Subgrp] & [Date 2] as ConKey
from tablename;
inner join(Test)
Load max(WEDAT) as WEDAT resident Test;
Hope it helps;
tab1:
LOAD
max(date([As of Date]) AS max_WEDAT,
[Emp #] [from ur source]
group by [Emp #] ;
tab2:
LOAD date(max_WEDAT) &'|'& [Emp #] as [WEDAT_Emp] Resident tab1;
tab3:
date(max_WEDAT) &'|'& [Emp #] as [WEDAT_Emp],
[As of Date] AS [WEDAT],
[Cost Ctr] AS [Profit Center],
[Emp #] AS [All.Emp #],
[Activity] AS [JobCode],
[Emp Subgrp] AS [All.Emp Subgrp],
[Date 2] AS [All.Date 2],
[As of Date] & [Cost Ctr] & [Emp #] & [Activity] & [Emp Subgrp] & [Date 2] as ConKey
[from ur source] where exists([WEDAT_Emp], date(max_WEDAT) &'|'& [Emp #]);
drop table tab2;
You can either drop tab1 or keep it to see the max WEDATE for each #Emp.
Hope its useful !!!
Regards
TAB1:
LOAD
FROM
(txt, codepage is 1252, embedded labels, delimiter is ',', msq)
TAB2:
Resident TAB1;
TAB3:
LOAD
FROM
(txt, codepage is 1252, embedded labels, delimiter is ',', msq)
where exists(, date(max_WEDAT) &'|'& );
drop table TAB2;
I don’t have the field labeled max_WEDAT on my source file. Should it just be WEDAT?
Thanks
Thom
u dont need max_WEDATE field form ur source
have u tried the code as i posted ?
just put whatever the date field nameis there in ur source of which max date per emp is needed.
you've mentioned [As of Date] field in ur case.
Regards
Yes. I have tried what you posted. The only error I am getting is what I have highlighted.
Thanks
i'm sure the solution will work.
Can u pls attach ur qvw ?
Thanks
can u pls load only this part of script & post if u get any error
i can't do it as i dnt have the csv file.
u shud only have 2 tables in ur data model then....Tab1 & Tab3 linked by [All.Emp #].