Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

Can you pass an expression as a parameter to the formula tool?


I created a config file for my workflow, and within the workflow, I read in the file and use the fields in a formula tool.   Within the formula tool I have start and end date fields that contain date expressions that I want to pass to the formula tool.  For example, the config file startdate field contains the following DateTimeFormat(DateTimeAdd(DateTimeNow(), -1 , "days"),"%Y-%m-%d" ).  It is currently getting passed to the formula as a string, and I'm looking to find out if there is a way to have the formula treat the field as an expression as opposed to string.  


Any help would be greatly appreciated.




Alteryx Certified Partner

Build a batch macro that uses the formula expression as a control parameter and an Action tool can update a Formula tool within that batch macro. I could help if you have questions about building this.


Otherwise, what needs to be dynamic about the formula? There might be an easier way.

@mattyo519 I think an eval type function would work if Alteryx implemented my idea:

Thank you Charlie.  There has to be an easier way than how I am approaching this.  A little more background, we are executing a python script that pulls data through from a vendor using their API.   I wanted to use the config file as means to change the date as needed without any changes to workflow to avoid our internal change control process. Basically the workflow will run daily and using the expressions directly in the formula solves the problem.  However, if an exception occurred we would be stuck.  My thought was to leave myself an option to dynamically pass in a new value.  I hope that makes sense.

That is exactly what I need Patrick, however I think that was submitted as an idea but not a solution.  But yes that is the functionality I am looking for,


hi @mattyo519 


Try the Dynamic Replace tool under the developer tab.  One of it's modes of operation is to evaluate formulas that are passed in.  You bascially pass a record set to the D input and a formula to the R input.  It replaces the field names in the formula with the values from the record set.  If you check the "Values are Expressions/Formulas" box it will also then evaluate the formulas.  It applies the same formula to all records in the D input, so if you want to have a different formula for each row you'll have to wrap the tool in a macro and pass one row and one formula at a time to it.  But if you want evaluate just one formula, it will do it out of the box