Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Knowledge Base

Definitive answers from Designer Desktop experts.

Optional Fields in a Macro Field Map

AndrewL
Alteryx
Alteryx
Created

Question

How do you make fields in a Field Map (Macro Input) optional like in the Heat Map tool?

2018-11-14_16-31-07.png

Answer

I was asked this question in the Solutions Center at Inspire this year, and as it turns out, it is surprisingly easy. Shout out to Chad Martin for providing the answer.

When you're setting up your Macro Input tool, make sure to use the Field Map option. After that, it's as easy as adding '(Optional)' next to the field names you want the user to not be required to map:

2018-11-14_16-35-51.png

The end result is an interface in the final macro that looks like the below:

2018-11-14_16-37-32.png

A very simple sample (built in 11.0) is attached for reference.

Attachments
Comments
patrick_digan
17 - Castor
17 - Castor

Holy cow, this is awesome! Thanks for passing it along.

Hollingsworth
12 - Quasar
12 - Quasar

So very happy to know this!

SeanAdams
17 - Castor
17 - Castor

:-) that's very useful, thank you - and something that no-one would know if you hadn't seen the internals
So I played around with at a bit - am I right that Alteryx is just doing a text-match for the exact string '(Optional)' to determine if a parameter is optional or not?

  • It is case sensitive - '(optional)' doesn't work.
  • It's also space sensitive - '( Optional)' also doesn't work.

Do you have a sense of when the parameters for macros are due for an overhaul to allow for strict typing?   When this hits the priority queue, it would worth managing the optionality of the input params in the same sprint.

 

Thanks for passing this on.

 

LordNeilLord
15 - Aurora

I've been trying to hack a solution to this all afternoon +1 * 1000000

joshuaburkhow
ACE Emeritus
ACE Emeritus

Can someone confirm this is still working? It's not working for me in 2019.3 or 2020.3 and for @pjungels https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Using-Optional-Macro-Inputs/m-p/645866

 

joshuaburkhow_0-1602035556810.png

 

 

@AndrewL @LordNeilLord @SeanAdams @Hollingsworth @patrick_digan 

patrick_digan
17 - Castor
17 - Castor

@joshuaburkhow @pjungels It truly is optional in the macro input. Here would be the error if we didn't put (Optional) at the end of the field name:

patrick_digan_0-1602094668992.png

 

With that said, not having the field may cause problems downstream. In your example, the formula tool is throwing an error because it was expecting a field called Test (Optional) which doesn't exist. The easiest work around is to use the ensure fields macro which is part of the crew macros. Alternatively, you can see in the heat map tool how they handled the optional field:

patrick_digan_1-1602094802461.png

 

 

pjungels
6 - Meteoroid

Thank you @patrick_digan! That is exactly what I was looking for. The Ensure Fields macro works perfectly for "cleansing" those optional fields for use within the macro. It's also nice to know there are workarounds to do this manually if needed.

john_watkins
11 - Bolide

The (Optional) argument isn't working for me with 2020.3.  FieldName[space](Optional)

pjungels
6 - Meteoroid

@john_watkins - it's working for me in 2020.3. Can you describe what you are seeing (error message, etc.)?

john_watkins
11 - Bolide

It runs my macro and throws an error stating that "The field [XYZ] (Optional) is not contained within the record.   This is possibly because I'm using it in the macro, but I assume if there is no value passed, that the tool would just set it to Null or something.   This may be an incorrect assumption.

 

pjungels
6 - Meteoroid

See the response from @patrick_digan above. In short, the Ensure Fields tool in the CReW macros helps to cleanse/normalize optional fields, adding them as NULL if they are not present.

john_watkins
11 - Bolide

I did name the field Optional and then did use the CReW macros to clean it up.  That was my final resolution to that issue.