Alteryx Designer Desktop Discussions

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

NEWBIE Question Re: Variables

TheSloopJohnB
6 - Meteoroid

Hi all -- brand new to Alteryx and have a question regarding variables. 

 

Is there a native tool or mechanism where you can create a variable that can be referenced by tools across the whole package? 

 

I come from an SSIS background where I was able to create a user variable that could be referenced at task or package level and updated as the package executed.  This was extremely handy for many things.  

 

So far, I'm not seeing a straight forward "non-MacGyver" way to do this -- but I'm still VERY NEW getting my sea legs with all of the tools.   

 

Thanks!

10 REPLIES 10
BrandonB
Alteryx
Alteryx

You can use workflow constants which create a variable that can be quickly referenced across an entire workflow. You navigate to this by going to the "Workflow" tab in the configuration window that can be accessed by clicking on a blank space on the canvas so a tool is not selected. 

 

constants.png

 

More info on constants here: https://help.alteryx.com/20231/designer/constants 

nagakavyasri
12 - Quasar

For expressions, you can create and save expressions in Formula tool & use this expression in the workflow from the 'Saved Expressions'

 

Create and save expressions:

 

Screenshot 2023-06-27 125156.png

 

 

 

Using saved expressions:

 

Screenshot 2023-06-27 125247.png

 

TheSloopJohnB
6 - Meteoroid

Thanks Brandon!  I remember seeing this when I first started a few days ago and I abandoned it, but couldn't remember why.  I think I remember why now after trying again. 

 

Is there a way to dynamically, or programmatically set the value of user variables at the time of and/or during execution -- or is it a hard coded?  

 

Thanks again. 

BrandonB
Alteryx
Alteryx

Yep! You can definitely set it up to be defined/selected by the user. Alteryx has the concept of an Analytic App which allows you to parameterize just about any setting of almost any tool on the canvas. This can be thought of kind of like a stored procedure where values are selected prior to run, except through ONE interface you can choose values that update queries across multiple sources and dynamically pick logic. The workflow can then be deployed on an Alteryx Server and leveraged as a utility by the rest of your organization (who has been granted access to it of course) 

 

You can read more about apps here: https://help.alteryx.com/20231/designer/analytic-apps 

 

You can explore sample workflows for the Interface Tools via Help > Sample Workflows > Learn one tool at a time > Interface.

 

If you want some free interactive training you can navigate to this section of the Alteryx Community where it walks you through step by step: https://community.alteryx.com/t5/Interactive-Lessons/tkb-p/interactive-lessons/label-name/Creating%2...

TheSloopJohnB
6 - Meteoroid

Thanks!  I've been working through the interactive lessons for the last couple of days.  I watched enough of the Analytic App videos to (perhaps too soon?) determine that wasn't the right path for what I'm trying to do.  

 

I need the workflow to set the variable itself at runtime without any user interaction and then store that variable for use at various points in the workflow.  (I need it to create a new folder at  a specific location based on the current date when executed.) 

 

A picture is worth a thousand words right?  So, at a high level -- I'm trying to accomplish the following:

 

  1. GROUP 1 - (Create Monthly Folder) -- Create a new folder at a given location for the previous month (e.g. - ...folderpath\202305 ) and then ....
  2. Store that path in a variable for use by GROUP 2 (Create Metric Folders)  and then ... 
  3. GROUP 2 - uses that variable to create a sub folder structure (e.g. ...folderpath\202305\metric1      ......folderpath\202305\metric2   etc)

 

Everything works right now...(I deleted a connector for the sake of the picture) ... but I'm trying to ensure GROUP 1 fully completes prior to GROUP 2 running because GROUP 2 has a dependency on knowing the parent folder before creating sub folders.

 

I would love to hear any feedback and know if dynamically updating variables without user input is possible. 

 

However, that said, the more I'm working on this and slowly learning the uses of the various tools and capabilities -- I think I'm slowly beginning to see how to lay this out.  Based on what I've read and watched -- it looks like the way to do this and control flow order is through a macro. 

 

Thoughts? 

 

TheSloopJohnB
6 - Meteoroid

@ nagakavyasri That just might work for what I need!!!!  Thank you!!!  I'm going to play around with it and will update.  

 

 

BrandonB
Alteryx
Alteryx

One of my favorite functions in Alteryx is DateTimeToday(). If you pair this with DateTimeAdd(), you can effectively pull the date that the workflow is being run dynamically into the workflow. You can also use DateTimeFormat() to format the date string into exactly what you want. From what you describe I think that you would do this entirely in a formula without having to use variables at all. 

TheSloopJohnB
6 - Meteoroid

Right -- I'm using DateTimeAdd() to determine the date and folder name.  I use that value to create the main folder. 

 

Within that folder -- I'm going to create subfolders.  I want to store the path of the main folder in a variable to use to create the sub folders to house metrics.  

 

  • main folder path\202305     <-- main folder -- store this in a variable and use to build the sub folders below
    • sub folder path\202305\metric1
    • sub folder path\202305\metric2

 

Apologies for the back and forth. I could probably do a better job explaining :)

BrandonB
Alteryx
Alteryx

Give this approach a try (attached). You can use the Append Fields tool to add the value of that base path to every single metric value that you have. I think that this gets to what you are going for. 

 

 
 

dynamic path creation.png

 

Labels