community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Upgrade Alteryx Designer in 10 Steps

Debating whether or not to upgrade to the latest version of Alteryx Designer?

LEARN MORE
SOLVED

Using variables in workflow

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?

Alteryx Certified Partner

@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

 

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?

 

 

Alteryx Certified Partner

@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.

 

 

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. 

Alteryx Partner

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

Labels