Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Using variables in workflow

Abhishek_Gupta
6 - Meteoroid

Is it possible in Alteryx to define some variables, allocate them value on run time and use them during the course of workflow.

 

Like I have a situation in which I need to use a calculation (number of records / Sum(some column)) across the workflow and I do not want to write this expression again and again. So is there any way that I could save this calculation in a constant or something and use it across the workflow?

7 REPLIES 7
jrgo
14 - Magnetar

@Abhishek_Gupta,

 

If your values are to be derived from the data that's being passed through, you can summarize (or use whatever tools to get your defined value) and then append it back into your main data set which you can then pass through and use in your downstream tools.

image.png

If you are defining variables that are static and not derived from the data, you can add new "Workflow Constants".

image.png 

In a Formula tool (or any tool that contains an expression builder), under the "Constants" you'll have your value to use where ever needed.

image.png

 

Abhishek_Gupta
6 - Meteoroid

Using constants will not solve the purpose as every time when the input file will change the value of the variable will also change as it would be calculated from the ingested data. 

 

I have a question regarding your 1st approach i.e. using a summarize tool. Would this be an optimized solution, as the same summarized value will get appended to each every record in the ingested data? Also I would like to know that is summarizing based on some conditions is possible or not?

 

 

jrgo
14 - Magnetar

@Abhishek_Gupta,

 

You should not see any significant impact with performance by doing this, but yes; you would be appending that value to every record in your dataset. You don't necessarily need to use a summarize tool, but the part that's important is that the data that you append from the source (S input) only contains ONE RECORD, otherwise end up with a Cartesian product, which would not be suitable based off my understanding of your use case.

 

The summarize tool is not a tool where a conditional statement can be applied. It's simply aggregating/summarizing your the data you feed into it based on how it's configured. You would need to prepare/filter your data before it hit the Summarize tool.

 

 

Abhishek_Gupta
6 - Meteoroid

@JRGO

 

Well I find this very strange that why Alteryx has not given the summarize function option in the "Formula" tool. I guess that would have been a more optimized approach rather that repeating the values again for the whole record set again and again. 

 

So I would be going with the solution which you have suggested. Thank you for the help. 

wenjuanchen
8 - Asteroid

I think Summarize function is not in Formula Tool because Formula Tool only conducts row-level calculation. Summarize is a multi-row function.

vaughangary
8 - Asteroid

I agree with the original question.  Would be fantastic to have a dynamic user defined variable.  For example, I found some cumbersome workarounds for dynamically selecting the last column of a table.  If we could assign a variable (field info, then count records), that would be much much easier to plug into the dynamic select tool as a direct solution.

vaughangary
8 - Asteroid
 

Picture1.jpg

Labels