Last modified: June 16, 2020

Constants are global variables for a workflow that are defined on the Workflow tab in the Workflow Configuration window. Constants make it possible to change a value in a single location and have that change apply to the rest of the workflow.

There are 3 types of constants:

  1. Engine: Five Engine constants display in every workflow and an additional constant, IterationNumber, displays when the Workflow Type is Batch, Iterative, or Location Optimizer macro.
    • TempFilePath: The directory where the engine will write temporary files.
    • Version: The version number of the Alteryx Engine installed on the machine.
    • WorkflowDirectory: The directory of the current workflow. If no workflow is open, the value will be the Alteryx installation directory.
    • WorkflowFileName: The file name of the workflow, which is only available if the workflow has been saved.
    • 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 is 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.
  2. Question: When the Workflow Type is Analytic App or Macro, many of the Interface tools display as Question constants. The name of the constant corresponds to the name of the Question tool. See Interface Tools.
  3. User: User constants can be created and edited via the Workflow configuration window.

Add a User Constant

  1. Select the add (+) button.
  2. Enter a Name and Value.
  3. Select the # check box if the value is a number. By default, constants are strings.

Delete a Constant

  1. Highlight the constant.
  2. Select the delete (-) button.

Use a Constant

Use a Constant in an Expression

Engine and user constants display as variables that can be used to build an expression in any tool that uses an expression editor. The data type for a constant is based on whether the constant is designated as a number or a string on the Workflow tab in the Workflow Configuration window. Question constants do not display in the expression editor. See Expression Editor.

Use a Constant via a Reference Shortcut

Any constant can be used in the configuration of a tool by using a reference shortcut. You can specify a constant variable by adding a % (percent sign) at the beginning and end of the name: %ConstantType.ConstantName% .

The reference shortcut can then be used in an expression editor or in a text box, and the constant can be updated via a Question tool or modified on the Workflow tab in the Workflow Configuration window.

Be cautious when using this method, as it may not always produce expected results.

Was This Helpful?

Running into problems or issues with your Alteryx product? Visit the Alteryx Community or contact support.