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.

Dynamic Field Add Macro - Given Conditions

marcmalitz
5 - Atom

Hi all,

 

I find myself constantly parsing through raw data and adding in the same fields to adhere to a format time and time again. Initially, I had thought it'd be easy enough to create a macro that'll add these fields regardless of the underlying data's fields (i.e. if I want to add a "Customer" field since that's recognized by the system but there's already a "Customer" field within the raw data), but to take it a step further, would anyone know how to add fields if certain conditions are met? I'll lay out the base scenario I'm running into and how I imagine the macro would act:

 

Raw data source contains the following fields [I'll call this "raw fields"]:

 

Invoice Number

Customer ID

Parent Customer

Quantity

Amount

Revenue

 

Required fields that system needs to upload [I'll call this "required fields"]:

 

1: Company ID

2: Customer ID

3: Amount

4: Quantity

 

How macro would act:

 

IF any of [raw fields] equals any of [required fields] THEN keep field(s) as they are ELSE add any missing [required field]s with a formula node ENDIF

 

Please feel free to reply with any questions and thanks in advance, community!

 

 

2 REPLIES 2
SPetrie
12 - Quasar

Im sure a macro could be created, but you may be able to get away with a union and text input tool.

If you have the default fields in a text input with no rows, you can union that to the workflow and any of the default fields will get added.

SPetrie_0-1660838473221.png

SPetrie_1-1660838510901.png

SPetrie_2-1660838549461.png

 

 

 

SPetrie
12 - Quasar

Just to take it a step further and tackle the original ask of doing it via macro where it decides what fields to add, I came up with this.

 

SPetrie_1-1660881072624.png

 

This version will compare the actual fields with the expected ones and only union the missing fields. 

 

I still believe that a simple union will do the trick, but there isnt anything stopping us from putting that into a macro either.

 

SPetrie_2-1660881173622.png

 

Both macros will give the same result of adding the missing fields.

SPetrie_4-1660881249539.png

 

SPetrie_3-1660881217849.png

SPetrie_5-1660881290850.png

 

 

 

 

 

 

Labels