Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Add max date field

Hi all,

I am trying to create an additional field (through my load script) called "Latest Date", which gives me the max LoginDate for each ID. So if max LoginDate for ID 2168 is 14-02-2017, then this date should appear in every row where ID = 2168.

How can I achieve this?

Thanks in advance!

1 Solution

Accepted Solutions
its_anandrjs

Here i need to ask if you have LoginDate in your table it self then try with


MainTable:

Load

ID,

LoginDate,

...

From Location;


Left Join(MainTable)

Load

ID,

DATE(MAX(LoginDate)) as MaxLoginDate

Resident MainTable

Group By ID;

View solution in original post

4 Replies
sunny_talwar

May be this

Fact:

LOAD ID,

     Date,

     OtherFields

FROM ...

Left Join (Fact)

LOAD ID,

     Max(Date) as [Latest Date]

Resident Fact

Group By ID;

Anil_Babu_Samineni

May be this?

Left join to fact

Load *, Max(Date) as MaxDate

Resident Fact

Group By <Non Aggr Dimensions>;

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
its_anandrjs

Here i need to ask if you have LoginDate in your table it self then try with


MainTable:

Load

ID,

LoginDate,

...

From Location;


Left Join(MainTable)

Load

ID,

DATE(MAX(LoginDate)) as MaxLoginDate

Resident MainTable

Group By ID;

Anonymous
Not applicable
Author

Thanks guys! All three answers were very helpful 

In the end Anand came closest to the solution which I could use directly in my code, so I will mark his answer as correct.

Thanks again.