Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
alec1982
Specialist II
Specialist II

Scripting help

Hi Guys,

I have the following table:

IDSubtypeDateTypeDate
117835 Commencement3/1/2002
117835 CPI Increase3/1/2002
117835 Expiration2/28/2015
117835Cancellation OptionNotice End3/1/2005
117835R of First RefusalNotice End2/28/2007
117835Renewal OptionNotice End8/31/2010
117835Termination OptionNotice End8/31/2009

I need to write a script to show the max date grouped by the ID and Date Type where the DateType ='Notice Date' and then show the value of the Subtype.

so my result table should look like:

117835     Termination Option     Notice End     8/31/2009

Let me know if you can help.

Thxs,

Alec

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

Assuming that your the above information in TempTable

TempTable:

Load

*

From....

NoConcatenate//used because of the table below also going to be in same struct

TempTable1:

Load *

Resident

TempTable where DateType='Notice End'

Order by ID,DateType,Date;

Load

ID,

LastValue(SubType) AS SubType,

DateType,

Max(Date) AS MaxDate

Resident

TempTable1

Group by ID, DateType;

Drop table TempTable, TempTable1;

View solution in original post

2 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Assuming that your the above information in TempTable

TempTable:

Load

*

From....

NoConcatenate//used because of the table below also going to be in same struct

TempTable1:

Load *

Resident

TempTable where DateType='Notice End'

Order by ID,DateType,Date;

Load

ID,

LastValue(SubType) AS SubType,

DateType,

Max(Date) AS MaxDate

Resident

TempTable1

Group by ID, DateType;

Drop table TempTable, TempTable1;

alec1982
Specialist II
Specialist II
Author

I guess I am very close:

LeaseOption:

LOAD

    ID,

    Median(Subtype) as [Option Type],

    DateType

     max(Date#(LEFT(Date,10),'YYYY-MM-DD')) as Date

RESIDENT

    KeyDate

where DateType='Notice End'

Group by

    ID, DateType ;

I think the only thing need to be fixed is the highlited line to show the right value.

Thxs,