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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to add new columns in script? Caculate date interval.

Hello everyone,

I have a table describe the test, include 4 fields (ID, TestType, Result, TestDate). I want to add new field when etl which can show last test date and how many months from last test.

The source table has 4 columns.

How to add 2 new columns (red color) in script when ETL?

Thank you very much.

I will demo next week, Please give me some idea. Thanks again.

IDTestTypeResultTestDatelastTestDateTestInterval(in month)
1A12231/1/2013  
2A1321/1/2013  
3A121/1/2013  
4A1231/1/2013  
5A2341/1/2013  
2A22/1/20131/1/20131
3A1232/1/20131/1/20131
4A133/1/20131/1/20132
1A1237/1/20131/1/20136
5A2348/1/20131/1/20137
1A238/1/20137/1/20131
2A12319/1/20132/1/20137
14 Replies
mdmukramali
Specialist III
Specialist III

Dear,

In your sample apps i used the same script i'm getting time interval values.

can you have look on the attachment of the sample file.

Thanks,

Mukram.

Not applicable
Author

I can't open the website and download the attachment. I will check this later. Thanks for your help.

Not applicable
Author

Hi,

     try this script

     LOAD

       *,

       Month(TestDate) - Month(LastTestDate) AS TestInterval;

     LOAD

       *,

       If(Peek('ID') = ID AND Peek('TestType') = TestType, Peek('TestDate')) AS LastTestDate

          Resident tempInterval

     Order By ID, TestType, TestDate;

I hope this will help you.

Thanks,

Ashutosh

Not applicable
Author

Hi Ashutosh,

Thank you for your help. Your script is wonderful:)

Not applicable
Author

Thanks for your qvw file.

I add order by ID, testType, testDate, it works:)