Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Add Recent Date Flag

Hi All,

I have a table containing the three values:

Transaction Timestamp,

New Value,

Old Value.

I load them as shown:

LOAD ID,

     [Old Value] ,

     [New Value] ,   

     [Transaction Timestamp],

     Timestamp#([Transaction Timestamp],'mm/dd/yyyy hh:mm:ss') as 'Formatted Timestamp'

FROM

My Table;

What I would like is to have a flag in the load script to identify the most recent transaction. Can someone please help me here? Do I need a self join with group by or is there a way I can check the value and add a flag in the same table? I am struggling with the syntax here as the timestamp field also need to be formatted ( as shown above)

Thanks,

Praveen

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Data:

LOAD ID,

     [Old Value] ,

     [New Value] ,  

     [Transaction Timestamp],

     Timestamp#([Transaction Timestamp],'mm/dd/yyyy hh:mm:ss') as 'Formatted Timestamp'

FROM

My Table;


LEFT JOIN(Data)

LOAD

ID,

Max(Formatted Timestamp) as 'Formatted Timestamp',

1 AS MaxTimeStampFlag

RESIDENT Data

GROUP BY ID;


Hope this helps you.


Regards,

Jagan.

View solution in original post

3 Replies
sujeetsingh
Master III
Master III

Table2:

LOAD ID,

     [Old Value] ,

     [New Value] ,  

     [Transaction Timestamp],

     Timestamp#([Transaction Timestamp],'mm/dd/yyyy hh:mm:ss') as 'Formatted Timestamp'

    interval(Today()-[Transaction Timestamp],'dd') as Recent

FROM

My Table;

FinalData:

Load ID

,min(Recent)

resident Table2:

drop table Table2;

SergeyMak
Partner Ambassador
Partner Ambassador

Hi

Try to add this script

LEFT JOIN (YourTableName)

LOAD

ID,

Max([Transaction Timestamp]) AS [Transaction Timestamp],

1 AS Last

Resident YourTableName

GROUP BY ID;

Regards,

Sergey

Regards,
Sergey
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Data:

LOAD ID,

     [Old Value] ,

     [New Value] ,  

     [Transaction Timestamp],

     Timestamp#([Transaction Timestamp],'mm/dd/yyyy hh:mm:ss') as 'Formatted Timestamp'

FROM

My Table;


LEFT JOIN(Data)

LOAD

ID,

Max(Formatted Timestamp) as 'Formatted Timestamp',

1 AS MaxTimeStampFlag

RESIDENT Data

GROUP BY ID;


Hope this helps you.


Regards,

Jagan.