Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
thanhphongle
Creator II
Creator II

Create End Date based on start date

Hello community,

 

is it possible to create in the script an "End Date" which is based on the "start date"?

Currently i get data from SAP where the start date of a price of an article is given but the end date is not.

 

See the table below

 

Article NoStart DateEnd DatePrice
100101.01.2020 100
100101.02.2020 90
100101.03.2020 100

 

Is there a possibilty to calculate the End-Date based on the Start date by calculating

if there s a previous Start Date then calculate the current data record of the start date -1 , else set End-Date = 31.12.2999

 

See example:

Article NoStart DateEnd DatePrice
100101.01.202031.01.2020100
100101.02.202029.02.202090
100101.03.202031.12.2999100

 

Hope anyone can help me here.

BR Le

1 Solution

Accepted Solutions
Taoufiq_Zarra

Maye be :

Data:
LOAD [Article No], Date#([Start Date],'DD.MM.YYYY') as [Start Date], [End Date] , Price INLINE [
    Article No, Start Date, End Date, Price
    1001,01.01.2020,,100
    1001,01.02.2020,,90
    1001,01.03.2020,,100
];

output:
noconcatenate
load [Article No],[Start Date],if(rowno()=1,Date#('31.12.2999','DD.MM.YYYY'),Date(previous([Start Date]-1),'DD.MM.YYYY')) as [End Date] ,Price;
load * resident Data order by [Start Date] DESC;

drop table Data;

 

output:

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

1 Reply
Taoufiq_Zarra

Maye be :

Data:
LOAD [Article No], Date#([Start Date],'DD.MM.YYYY') as [Start Date], [End Date] , Price INLINE [
    Article No, Start Date, End Date, Price
    1001,01.01.2020,,100
    1001,01.02.2020,,90
    1001,01.03.2020,,100
];

output:
noconcatenate
load [Article No],[Start Date],if(rowno()=1,Date#('31.12.2999','DD.MM.YYYY'),Date(previous([Start Date]-1),'DD.MM.YYYY')) as [End Date] ,Price;
load * resident Data order by [Start Date] DESC;

drop table Data;

 

output:

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉