Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Splitting Records Based on Dates

jrdnjhnsn2
7 - Meteor

Hey all,

 

I've got a bunch of policy data that has issue date and termination date (which may or may not be null). I'm trying to figure out how to split each record based on its "policy anniversary." 

 

For example, let's say a policy has an issue date of 10/10/2007 and termination date 12/10/2009. I want to create separate records for each of these date ranges:

  1. From 10/10/2007 issue date though 12/31/2007.
  2. From 1/1/2008 through 10/9/2008.
  3. From 10/10/2008 through 12/31/2008.
  4. From 1/1/2009 through 10/9/2009.
  5. From 10/10/2009 through 12/10/2009 (the termination date).

Using DummyID 4 in my sample data as another example, my desired output is as follows:

DummyIDPolicy_Start_DatePolicy_End_Date
41954-09-201954-12-31
41955-01-011955-09-19
41955-09-201955-12-31
41956-01-011956-09-19
 . 
 . 
 . 
42019-09-202019-09-24

Does anyone know how this can be done?

11 REPLIES 11
jrdnjhnsn2
7 - Meteor

Thanks, @DavidP! That's a thing of beauty. Works perfectly.

DavidP
17 - Castor
17 - Castor

Sorry @jrdnjhnsn2 this is getting very embarrassing, I keep messing up the multi-row formula to accommodate all the different angles and in trying to fix one thing, I break another.

 

As a result, the previous version was wrong too. The attached workflow is the final version where everything works they way it should.

 

The multi-row formula should be:

 

IF

 

IsNull([Row-1:Period Start]) OR
tostring(DateTimeYear([Period Start]))+'-01-01'!=[Period Start] OR
tostring(DateTimeYear([Issue date]))+'-01-01'=[Issue date]

 

THEN

 

tostring(DateTimeYear([Period Start]))+'-12-31'

 

ELSE

 

DateTimeAdd(DateTimeAdd([Row-1:Period Start],1,'year'),-1,'day')

 

ENDIF

 

 

Labels