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: 
Iwin
Partner - Creator
Partner - Creator

Create End dates based on next start date for a dimension

Hi,

I have a requirement where I need to create end dates based on start dates.

I have explained the scenario below : 

Iwin_0-1727335641056.png

 

Here for Patient A ,the end date of Free Use is null but as Commercial Order Type started on  07 /07/2024 ,the End Date for Free Use should display date 1 day before the start date of Commercial Order Type i.e - 06/07/2024

For Patient B, there are 3 Order Types ,and there can be any number of Order Types for a Patient.

How to create the end dates in this scenario?

 

 

Labels (2)
1 Solution

Accepted Solutions
VBD
Partner - Creator
Partner - Creator

Hello, 

You can try something like : Test :
Load Patient,
[Order Type],
[Start Date],
if(Previous(Patient) = Patient and len([End date]) =0 , date(peek([Start Date],-1)-1),[End date]) as [End date]
Resident TMP
Order by Patient asc, [Start Date] desc;

ValentinBld_1-1727337670544.png

 

 

Valentin Billaud
Next Decision

View solution in original post

2 Replies
VBD
Partner - Creator
Partner - Creator

Hello, 

You can try something like : Test :
Load Patient,
[Order Type],
[Start Date],
if(Previous(Patient) = Patient and len([End date]) =0 , date(peek([Start Date],-1)-1),[End date]) as [End date]
Resident TMP
Order by Patient asc, [Start Date] desc;

ValentinBld_1-1727337670544.png

 

 

Valentin Billaud
Next Decision
Iwin
Partner - Creator
Partner - Creator
Author

Thank you for the quick reply and fix.