Alteryx Server Discussions

Find answers, ask questions, and share expertise about Alteryx Server.
SOLVED

Data Manipulation Issue

oswinhull
6 - Meteoroid

Hello Alteryx community,

 

I was wondering if anybody on here could help me figure this out. 

 

Basically I have a data set like this:

 

ID1DATESTATELATLONGAGEGENDER
46110541275Pennsylvania40.3467-79.85590::200::Male||1::Male||3::Male||4::Female
46072641275California33.909-118.3330::200::Male
47885541275Ohio41.4455-82.13770::25||1::31||2::33||3::34||4::330::Male||1::Male||2::Male||3::Male||4::Male
47892541279Colorado39.6518-104.8020::29||1::33||2::56||3::330::Female||1::Male||2::Male||3::Male
47895941281North Carolina36.114-79.95690::18||1::46||2::14||3::470::Female||1::Male||2::Male||3::Female
47894841281Oklahoma36.2405-95.97680::23||1::23||2::33||3::550::Female||1::Female||2::Female||3::Female||4::Male||5::Male
47936341293New Mexico34.9791-106.7160::51||1::40||2::9||3::5||4::2||5::150::Male||1::Female||2::Male||3::Female||4::Female||5::Male

 

I need it to become like this:

 

ID1ID2GENDERAGE
4611050Male20
4611051Male 
4611052  
4611053Male 
4611054Female 
4607260Male20
4788550Male25
4788551Male31
4788552Male33
4788553Male34
4788554Male33

etc..

 

I have never seen data structured in this way before. I don't know if its a common format I'm just not aware of. Is there an easy way to do this? Any help would be appreciated.

 

Thanks.

 

2 REPLIES 2
NicoleJohnson
ACE Emeritus
ACE Emeritus

You should be able to do this with a few instances of the Text to Columns tool - my recommendation would be to first replace all of the double delimiter characters with single characters in the Age & Gender fields (i.e. || becomes | and :: becomes :). Then, using the Text to Column tool, Split your Age into rows for | delimiter, then Text to Column again splitting Gender into columns with the : delimiter... repeat the process in a separate stream for Gender... then use Join & Union with some data cleanup to get your data all back together in one list. 

 

If you need to show the blanks for ID2 that didn't have an age or gender specified, you can do so by determining the min & max ID2 for each ID1... then Generate Rows for every number between the two... then join this list back to the data from above, and union any leftover ID1/ID2 combinations to create the full list.

 

I've attached a sample workflow - hope this helps get you pointed in the right direction! :)

 

Cheers,

NJ

oswinhull
6 - Meteoroid

I was kind of hoping there was an easier way to do it. Apparently not.