Showing results for 
Search instead for 
Did you mean: 

Alteryx Designer Knowledge Base

Definitive answers from Designer experts.

The highly anticipated Alteryx Community tradition is back! We hope you'll join us!

Learn More

All About Constants

Alteryx Alumni (Retired)
Created on

You're working on your gazillionth Formula tool and "Jeff" from Quality Assurance sends you an email that the margin of error for your process has been restandardized. It's not 0.122 anymore but 0.121. Then the horrible reality sets in - you're going to have to go back through all of your formulas and update that one.. stupid.. little.. number.


You vow that you'll never again let smug "Jeff" ruin your night with his nitpicky tolerance standards, so you open up your browser, load up your home page (the Alteryx Community page duh), and find exactly what you've been looking for: a Knowledge Base article about document constants.


So what's a constant? According to the Alteryx Help pages: "Document Constants are global variables for a workflow. Constants make it possible to change a value in a single location and have that change propagate to the rest of the workflow."


You can find constants in your Workflow Properties tab (Click on the canvas and go to Workflow in the Configuration Window).




The "Is Numeric" checkbox on the far right will make the value numeric rather than a string.


Types of Constants



Those four Engine constants will show up in every workflow, and an additional constant, IterationNumber, pops in there when you are authoring a Batch, Iterative, or Location Optimizer macro.

Temp File Path: The directory where the engine will write temporary files.

Version: The version number of Alteryx engine installed on the machine.

Workflow Directory: The directory of the current workflow. If no workflow is open, the value will be the Alteryx installation directory.

GuiInteraction: A Boolean value indicating whether or not a workflow is being run from the GUI. When a workflow is run from the Alteryx Designer or Analytic App interface, the returned value will be True or 1. When a workflow is run from command line, the returned value is false, or 0.

IterationNumber: An integer that corresponds to the number of times a macro has run, starting at 0.



Clicking on the add.PNG symbol will allow you to add User Constants. In the above screenshot, I added a "Favorite Number" User Constant. These can be strings or numerics, and will stick with the workflow if you send it, schedule it, or upload it to a Gallery.



If you're making an app or macro, many of your Interface Tools will show up as Question Constants. The name of this constant will correspond to the name of the tool in the 2018-11-14_15-51-08.png Annotation area of the Tool Properties.




How to use constants


Formula Method

You can bring in a constant in any tool with a Formula Processor component, such as in the Formula, Filter, and Dynamic Rename tools.





Engine and User constants will populate under the Constants menu in the Variables. They will come in as either numeric or string based on whether that Is Numeric checkbox is checked off.

Question constants will not show up in this menu, and cannot be typed in [...] notation like the other variables.



Reference Shortcut

Any constant (Question included) can be called upon in any configuration option using a reference shortcut. This may not always work exactly like you think it will, so use this method with caution.


Generally, in any configuration you can type into, you can bring in a constant by using the notation %Type.ConstantName%. For example, in our Formula tool, we could refer to that Question constant in our Expression Editor.




Note we still had to place it within quotes, because these do not come in with our constant value.


Using the reference shortcut, we can pass along data without even connecting up the Interface tool to the formula.




Above we have a macro with the text box named "Constant", and below is the result when run in another workflow.





Check out the attached example to see it all in action! (compiled in version 10.1)



Hello 🙂


How can I build it in order for this constant variable to be a date that the user types in? The idea is that the parameter will be used to query the database, for example, and then the same value will serve to add to the file we output.

Alteryx Alumni (Retired)

Hi @Su!


If you would like to have the user type in the value for a constant in an app, you just need a Text Box tool like in the picture below.




You could name it anything you like instead of "Constant", and you would just refer to it in the form of "%Question.Constant%".

You could also possibly use the output of the Date tool instead, but this will always return the format "yyyy-mm-dd" which may not necessarily be what you need.


Can a constant be used in a SQL query or do you have to feed the constant via a control input for a macro with a data input node inside it?

@JMoore that's how I ended up in this thread also.  Wondering if it can be used in my SQL queries.



Any updates to whether we can use constants in SQL queries? It would make our workflows so much more robust.


To use a constant in a SQL is complicated I found but feed a constant into something (data input or formula) then run SQL query inside of dynamic input and adjust the query with a replace command, this is the general idea although I have yet to do it as I moved on from the issue.

I seem to be able to call constants just fine in my SQL queries using the following syntax : '%Type.Name%'

Is there any way to use one constant to define another? Example: I have the constant User.ClientName, which equals "ABC Co."

I want to define another constant named User.FolderPath, using "C://Documents/%User.ClientName%/Reports". But when I try to set this up in this way, Alteryx errors out and says it can't find the folder with that path. 


Thoughts, anyone?


@somolov If you're still searching for this: You may not be able to create a constant file path like this, but you should be able to dynamically create one with the Formula tool and the following expression:


"C://Documents/" + %User.ClientName% + "/Reports"



We have multiple people working on workflows with varying degrees of experience.  To streamline our process we want to reuse workflow sections as much as possible and make certain edits without requiring users to search for and update controls throughout the workflow(s). 


For the User Interface tools, we were wondering if we can use constants in the configuration of the UI tools.  For example, in the text tool, can constants be used to place text in the "Default Text" box.  That would allow us to change a single constant that may update multiple UI elements accordingly.  It would also make teamwork easier as we can train people to make certain edits to constants instead of more complicated workflow edits.


We attempted to put %User.VariableName% into the text box without success.  Is there another way?

Alteryx Partner

@WSData, I had the same doubt as you. In case you're still searching, take a look at this article: