Alteryx Designer Desktop Discussions

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

Harmonising Fields after Batch Macro Union

jay_hl
7 - Meteor

I have inputted a number of excel files through a batch macro. They all have slightly different schemas (field names) so the macro is set to union the results on output. 

 

This then ends up with multiple different fields for what is in reality the same field (eg Name, Names, FullName, Fullname) where lots of the rows are blank depending on what was in the source data.

 

Is there a quick and easy way to harmonise these to the same column?  My natural instinct would be to write a formula like the below:

 

If Name is not null, then Name, elseif Names is not null then Names elseif FullName is not null then FullName etc.

 

Given there are approximately 10 “real fields” across 30 variations I wondered if there was a best practice to tackle this and align all the data to a single column easier than nested ElseIfs

 

Jay

7 REPLIES 7
pedrodrfaria
13 - Pulsar

Hi @jay_hl 

 

You have different ways to approach this.

 

If they are always the same file structure, you can use the Union tool to manually assign everything to the correct place.

 

If you know that columns will always say Quantity or Qty or Quant or QTYs, etc. you can use the Dynamic Rename and create a If Contains logic to change the name to a single name throughout all the tables.

 

You can also do a logic with the Dynamic Rename, Select and the interface Dropdown to dynamically select the column that represents that specific column, and use the dynamic rename and the select to rename it to the proper name and the select to only select that column.

 

Please let us know which way works best for you and then we can better support you.

 

Pedro.

jay_hl
7 - Meteor

I just updated my original post.


I realised that the obvious solution for figures (like Quantity in the original post) is to sum it all to a new column, but the majority of the field types are strings (which I can’t sum!)

pedrodrfaria
13 - Pulsar

Hi @jay_hl 

 

What I mentioned before still applicable to the fields being a string value.

jay_hl
7 - Meteor

Thanks for the speedy reply Pedro.

 

Does Dynamic Rename allow the resulting logic to output the same field name multiple times. If I renamed Name, Names, Fullname all to be “Full Name” that would be 3 fields with the same (which I didn’t think was allowed)?

 

Then how would the three separate fields merge without writing nested Ifs in a formula tool?

 

Jay

pedrodrfaria
13 - Pulsar

If these fields are coming from different files, you do this logic before the union, and then the union will consider those fields.

 

If they are on the same file, then we would need to do a Transpose, Formula, Crosstab logic. To transpose it vertically, assign the same names to the rows of data and then crosstab it all together.

 

Pedro.

pedrodrfaria
13 - Pulsar

I attached an example with the second logic I mentioned.

Before:

 

pedrodrfaria_0-1613738275259.png

After:

pedrodrfaria_1-1613738281926.png

 

Pedro.

 

SeanAdams
17 - Castor
17 - Castor

Hey @jay_hl 

What you could do is to do a transpose (to get columns into rows), then a lookup / find & replace (using a static translation table in the text input tool; into a Find-replace) to change the field names; and then use Crosstab to re-explode them out to columns.

Labels