We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Macro XML Question - Raw XLM in Action tool is only detecting first word in field name

bkreutz0422
6 - Meteoroid
Hello,
 
I have created a macro that distributes a chosen value across rows according to chosen weight and group fields to be used as a custom tool for my team. The macro works great, but I am running into one very perplexing issue. I am attempting to update the Raw XML of a formula tool using an Action tool (see attached Macro Screenshot file). However, for some reason that I have been unable to solve, this step fails when the chosen Weight and/or Value field contains a space in the field name. 
 
For example, if the user chooses a field called "Dollars" and "DaysAvailable" (no spaces) as the Value and Weight fields, the macro runs successfully. However, if the user chooses a field called "Revenue Dollars" or "Days Available" (with spaces) as the Value and/or Weight fields, the action tool seems to only detect the first word of the chosen field and therefore fails and produces the following error messages:
 
Parse Error at char(0): Unknown variable "Days" (Expression #1)
and Parse Error at char(0): Unknown variable "Revenue" (Expression #2)
 
The Action tool inputs are set to the following:
[#1] = User-Chosen Weight Field
[#2] = User-Chosen Value Field
 
It is currently updating the raw XML of the formula tool with the following:
 
if [#1] = '' then 
'<FormulaField expression="1" field="Weight_Chosen" size="8" type="Double" />'
else
 '<FormulaField expression="'+[#1]+'" field="Weight_Chosen" size="8" type="Double" />' 
endif
+
if [#2] = '' then 
'<FormulaField expression="0" field="Value_Chosen" size="8" type="Double" />'
else
'<FormulaField expression="'+[#2]+'" field="Value_Chosen" size="8" type="Double" />' 
endif
 
Is my XML formula somehow restricting the Weight and Value fields to the first word in a field name? Suggestions to correct this would be very much appreciated!
 
See attached for the files. 
 
Thanks in advance!
2 REPLIES 2
patrick_digan
17 - Castor
17 - Castor

@bkreutz0422 That is an interesting one! Alteryx needs bracket around the field names whenever it has spaces. I've added brackets to your code. Give it a shot!

if [#1] = '' then 
'<FormulaField expression="1" field="Weight_Chosen" size="8" type="Double" />'
else
 '<FormulaField expression="['+[#1]+']" field="Weight_Chosen" size="8" type="Double" />' 
endif
+
if [#2] = '' then 
'<FormulaField expression="0" field="Value_Chosen" size="8" type="Double" />'
else
'<FormulaField expression="['+[#2]+']" field="Value_Chosen" size="8" type="Double" />' 
endif
bkreutz0422
6 - Meteoroid

@patrick_digan You are a life saver! Worked! I've been trying to figure this out for longer than I would like to admit. Thanks a ton!

Labels
Top Solution Authors