Alteryx Designer Desktop Discussions

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

Arranging the data

bb
7 - Meteor

Hello everyone,


I have a tons of rows of data that looks like this:

CityTownNameValue
BostonCambridgeDatabase 1Apple
BostonCambridgeDatabase 1 TypeSql
BostonCambridgeDatabase 1 URLhigh
BostonCambridgeDatabase 1 Server 1 FQDNft123yee
BostonCambridgeDatabase 2Orange
BostonCambridgeDatabase 2 TypeOracle
BostonCambridgeDatabase 2 URLlow
BostonCambridgeDatabase 2 Server 1 FQDNash67qweu
NYRochesterDatabase 1Banana
NYRochesterDatabase 1 TypeSql
NYRochesterDatabase 1 URLmedium
NYRochesterDatabase 1 Server 1 FQDN123hasd98

 

I need to arrange the data in such a way that it lines perfectly based on City and Asset. So basically if it's the same city and sametown and want anything that has number after database, it should place it in different column as Database. Similarly, All the database type should be in the new column for database type and so on.

 

The output should look like this:

 

CityTownDatabase Database TypesiteFQDN
BostonCambridgeAppleSqlhighft123yee
BostonCambridgeOrangeOraclelowash67qweu
NYRochesterBananaSqlmedium123hasd98

 

Anyone knows how to do this? Thanks in advance!!

4 REPLIES 4
JosephSerpis
17 - Castor
17 - Castor

Hi @bb I mocked up a workflow that produces the output as described. Let me know what you think? Arranging_Data_210819.png

JosephSerpis
17 - Castor
17 - Castor

Hi @bb  I mocked up a workflow let me know what you think? 

 

Arranging_Data_210819.png

Cal_A
7 - Meteor

Hi BB,

 

JS420's solution is great and uses the powerful RegEx tool.  If you find this tool a little opaque/scary you  can also breakdown the Name column using the formula tool.

 

The objective:

Before you can use Cross-tab you need to get to a point where you have a column of (future) headers and their corresponding values. Like the below picture:

crosstab.GIF

 

i.e. something like this for Headers/Data fields

HEADERSValues
DatabaseApple
TypeSql
URLhigh
FQDNft123yee
DatabaseOrange
TypeOracle
URLlow
FQDNash67qweu
DatabaseBanana
TypeSql
URLmedium
FQDN123hasd98

 

BUT You also need a way for the CrossTab tool to group (ie delineate) database1 and database 2.  Otherwise it will try to combine Apple+Orange into one row, because they are both Boston/Cambridge.

 

So, you have to split the Name column to give you two parts

Part1 = Database #

Part2 = New "Header" (e.g. Datebase Name, Type, URL, FQDN)

 

This can be done with a formula tool using 2 entries

1) Create new column for the header using this formula. Call the column "Header".

IIF(Length([Name]) = 10,"Database",Substring([Name],11))

2) Replace the existing "Name" column with this formula:

substring([Name],9,1)

 

You can now use CrossTab

  • Grouping fields are City, Town, Name (Name now contains either 1 or 2)
  • New Column Headers = The new column you created called "Headers"
  • Values = "Value" field.

something like thissomething like this

 

good luck

 

 

 

estherb47
15 - Aurora
15 - Aurora

Hi @bb 

And yet another approach here. If the Name column always contains the text that you shared, then you can solve for the column headers using a simple IF/THEN/ELSEIF and Contains function. The First function, Row, gives the number from the name column, which is needed to build the rows out with the Crosstab tool. Substring takes characters that don't come directly from the left or right side of the field. Just remember that it's zero-based, meaning the leftmost character is in the 0 position (which makes it different from Excel's MID function if you're used to using that)

 

image.png

 

I love using RegEx, but it can take longer in some cases, so I find that I use regular text functions instead, in cases where they will work.

A Crosstab tool rebuilds the table. @Cal_A provides a fantastic explanation as to the process.

 

Let me know if that helps.

 

Cheers!

Esther

Labels