Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

How to I transpose the data below to a single observation

Carolyne
8 - Asteroid

How do I transpose the data below  to a single observation:

 

Member IDFill Date

index date

days_supply
6032/17/20052/17/200530
6036/13/20052/17/200530
6038/11/20052/17/200530

 

 

End goal is for the data above to look like this:

 

Member IDFill date 1Fill date 2Fill Date 3days supply 1days supply 2days supply 3Start DateEnd Date
6032/17/20056/13/20058/11/20053030302/17/20058/15/2005

Thanks!

5 REPLIES 5
CharlieS
17 - Castor
17 - Castor

I started by using a Tile tool to assign a Record ID to each fill date that is unique for each Member ID. After that, a Transpose and a Cross Tab tool took care of most the heavy lifting.

 

An example solution is attached.

tcroberts
12 - Quasar

Hi I've put together a sample workflow for you:

n_fieldtranspose.PNG

 

Essentially I use some REGEX_Replace to turn each of the fields into a number, and check the value 3 rows ahead (which is the same field, for the previous record) to see what the number should be. If there is no number, it becomes a 1, otherwise you add one.

 

I then filter out unwanted fields, compute the maximum and minimum fill dates, CrossTab the data back into a horizontal format, and join in the start and end dates on Member ID.

 

To do this with additional members, just remember to group by MemberID in the Transpose, CrossTab, and MultiRow Formula Tools.

 

Let me know if this works for your use-case\

 

Cheers!

 

jeff_reynolds
10 - Fireball

The attached workflow should work for what you're looking for. 

Carolyne
8 - Asteroid

Thank you for your help. 

 

Follow-up Question: how do I take the last data set:

 

Member IDFill date 1Fill dAte 2Fill Date 3days supply 1days supply 2days supply 3Start DateEnd Date
6032/17/20056/13/20058/11/20053030302/17/20058/15/2005

 

 

and transpose: Please see below: This will require me using loops and arrays to find the days of medication coverage for each member and calculates the proportion of covered days in the review period. In this case the covered proportion of days covered is 65 over  180 days or .361

 

Member IDDay 1Day 2Day 3Day 4Day 5Day 6Day 7Day 8Day 9Day 10Day 11Day 12Day 13Day 14Day 15Day 16Day 17Day 18Day 19Day 20Day 21Day 22Day 23Day 24Day 25Day 26Day 27Day 28Day 29Day 30
603111111111111111111111111111111
 Day 31Day 32Day 33Day 34Day 35Day 36Day 37Day 38Day 39Day 40Day 41Day 42Day 43Day 44Day 45Day 46Day 47Day 48Day 49Day 50Day 51Day 52Day 53Day 54Day 55Day 56Day 57Day 58Day 59Day 60
 000000000000000000000000 00000
                               
 Day 61Day 62Day 63Day 64Day 65Day 66Day 67Day 68Day 69Day 70Day 71Day 72Day 73Day 74Day 75Day 76Day 77Day 78Day 79Day 80Day 81Day 82Day 83Day 84Day 85Day 86Day 87Day 88Day 89Day 90
 000000000000000000000000000000
                               
 Day 91Day 92Day 93Day 94Day 95Day 96Day 97Day 98Day 99Day 100Day 101Day 102Day 103Day 104Day 105Day 106Day 107Day 108Day 109Day 110Day 111Day 112Day 113Day 114Day 115Day 116Day 117Day 118Day 119Day 120
 000000000000000000000000001111
                               
 Day 121Day 122Day 123Day 124Day 125Day 126Day 127Day 128Day 129Day 130Day 131Day 132Day 133Day 134Day 135Day 136Day 137Day 138Day 139Day 140Day 141Day 142Day 143Day 144Day 145Day 146Day 147Day 148Day 149Day 150
 111111111111111111111111110000
                               
 Day 151Day 152Day 153Day 154Day 155Day 156Day 157Day 158Day 159Day 160Day 161Day 162Day 163Day 164Day 165Day 166Day 167Day 168Day 169Day 170Day 171Day 172Day 173Day 174Day 175Day 176Day 177Day 178Day 179Day 180
 000000000000000000000000011111
                               
                               
 Days Coveredp_days_covered                            
 650.36111                            

 

jeff_reynolds
10 - Fireball

So this one should at least point you in the right direction. I added another "member" in order to ensure that my groupings worked as intended. 

Labels