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

Load Script - create new column values based on existing date columns

Hi

I have a data table I am loading whereby I am first creating a new column which takes the Contract Start Date PLUS the Contract Tenure.

What I wish to do is look at this new date column and create a brand new column which states whether the customer is 'In Contract' or 'Out of Contract'. This would be based on whether the date was before or after the date of the load (I have created a variable vToday which I think I can incorporate.

I cant find anything in community which points me in the right direction.

Any advice/solutions out there?

Thanks

Martin

Message was edited by: Martin Hamilton Added as a sample

1 Solution

Accepted Solutions
Not applicable

Martin,


I noticed in your load script you used AddMonths to add the Contract Tenure to the Contract Start Date. I believe you need to do the same when using the formula from Mindaugas.


So, update the formula to be:


IF(Today() <= AddMonths ([Contract Start Date],[Contract Tenure]) , 'In Contract', 'Out of Contract') as [Is in contract]

From Source

Without the AddMonths, the formula is probably adding the Tenure as days instead of months.

Hope this helps!

- Stan

View solution in original post

6 Replies
Siva_Sankar
Master II
Master II

Martin,

Need a sample to show also not understanding whether load date is column which is already exsting in your data model.

You may create a load date (dashboard refresh date) using below

Date( floor(ReloadTime()),'DD/MM/YYYY') as  LoadDate

then  create an if statement using the above date to generate in contract column and out of contract column

Siva

MindaugasBacius
Partner - Specialist III
Partner - Specialist III

Use IF statement in your data model like:

Load

     [Contract Start Date]

     ,[Contract Tenure]

     ,IF(Today() <= [Contract Start Date] + [Contract Tenure], 'In Contract', 'Out of Contract') as [Is in contract]

From Source;

martin_hamilton
Creator
Creator
Author

Hi Mindaugas - I have added the logic you provided into my load script but it doesnt seem to be taking into consideration the actual contract end date but looks at the contact start date. Can you take a look and see where I am going wrong? Because I am creating a new contract end date i was sure whether it was possible to produce a look up as part of the load to generate the new column?

Thanks

martin_hamilton
Creator
Creator
Author

Hi Siva - I have uploaded a sample which incorporates the suggested approach from Mindaugas.

Not applicable

Martin,


I noticed in your load script you used AddMonths to add the Contract Tenure to the Contract Start Date. I believe you need to do the same when using the formula from Mindaugas.


So, update the formula to be:


IF(Today() <= AddMonths ([Contract Start Date],[Contract Tenure]) , 'In Contract', 'Out of Contract') as [Is in contract]

From Source

Without the AddMonths, the formula is probably adding the Tenure as days instead of months.

Hope this helps!

- Stan

martin_hamilton
Creator
Creator
Author

Thats exactly what it was doing! thanks Stan