Alteryx Designer Desktop Discussions

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

Adjust Macro to Account for the Presence or Abscense of a Field

hellyars
13 - Pulsar

I am trying to parse a set of records to extract relevant data.

 

The incoming stream can be divided into 2-3 subsets A, B, C.  The subset will determine the extraction method. (The 3 tan boxes in the image below).  Each subset will contain a key OuterXML field that identifies it:  A = A_OuterXML, B = B_OuterXML, and C = C_OuterXML.

 

I have 2 source XML files.  Source 1 includes A, B, and C.  Source 2 only includes A and B.  Presently, I have two separate macros that parse each Source.   I want to combine the two macros into one that can account for the presence or absence of C.

 

How can I adjust my macro to account for the presence or absence of C (C_OuterXML)?

 

The macro current fails if C is not present.  I can modify by adding an Ensure Field tool to the C box and then filter null values out -- bu then I have to add an Ensure Field tool for every missing xml field in the C workflow.  I assume there is a better way.

 

 

hellyars_0-1649963024346.png

 

4 REPLIES 4
hellyars
13 - Pulsar

I should add....

 

The presence or absence of C is only known after you attempt to parse for it

danilang
19 - Altair
19 - Altair

Hi @hellyars 

 

Try this

-Convert this macro into a batch macro with a control parameter connected to disable container C if C_OuterXML if false.

-Embed this macro in a new macro which only looks for C_OuterXML.  If found, pass true to the control parameter, otherwise pass false.

 

Dan   

hellyars
13 - Pulsar

@danilang  Can't argue with the logic, but I have no clue how to do that.  I actually tried and got stuck.

The good news, I can parse and output everything I need.  I am going back and trying to find synergies using macros etc. to reduce tools, steps, and in this case the # of workflows.

danilang
19 - Altair
19 - Altair

Hi @hellyars 

 

Here's an example of how to disable a container in a macro based on the presence/absence of a field in the calling workflow

danilang_3-1650111118819.png

 

In the main workflow, the Logic to disable the container in the macro uses a Field Info tool to extract the field names and then counts the number of C_OuterXML fields.  If the Count=0 then pass True to the Disabled attribute, else pass False.  Change the config of "Field selector" to simulate the presence/absence of the C_OuterXML field.   The  "Empty C_OuterXML field" on the bottom is just to ensure that the field exists before passing it to the macro. 

 

MacroMacro

 

Inside the macro, the "C_OuterMXL Disabled?" parameter controls the state of the Disabled flag on the third container.  If it's passed a "True", then the container is disabled.  The rest of the macro is just to demonstrate the concept  and have a variable output.

 

When c_OuterXML is present, the container is enabled in the macro and the output includes it

danilang_4-1650111341303.png

If it's missing, you get this

danilang_5-1650111382474.png

Dan

 

Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels