Hello everybody!
As I am new to Alteryx please be so kind and correct me in cases of abusing the "usual alteryx notation".
My question is the following one:
How can I assign a value, which I computed in a workflow to a "global variable" or constant in order to use it in the workflow again?
Toy-Example:
Given the following table:
A | B |
1 | 4 |
2 | 5 |
3 | 6 |
Workflow :
1) Compute the mean of A,
For example this could be solved using the in-buildt summarize tool
2) Store the mean of A in a "global variable", e.g. avg_A:=mean(A)
3) substract avg_A from each entry of the column B
For example this can be done by the in-buildt formula-tool
The "Pseudo-code" for this Toy example would look like :
#Assume A, B are simply vectors and not a matrix and A[i] denotes the i-th row/component of A #1stdeclare a variable/constant var mean_A=0; #2nd compute the mean of the values of A for(i=1,length(A),i++) { mean_A=mean_A+ A[i]; } mean_A=mean_A / lenght(A); #3rd substract mean_A from each component of B for(i=1;length(B),i++) { B[i]=B[i]-mean_A; }
Solved! Go to Solution.
Thank you jarrod for your answer!
Unfortunately I do not know how to append the value "avg_colA" to the entire set.
Maybe therefore it is worthful going back to the toy example : (especially also to check, if I understood you correct)
Input :
A | B |
1 | 2 |
2 | 3 |
3 | 4 |
Using the summary tool we get a "table" looking like
record | AVG_A |
1 | 2=avg_colA |
(here I explicitly wrote an equation to have on the one hand a numeric example and on the other hand to clearify the notation, i.e. AVG_A is the column/field name, avg_colA is the value)
Now I am looking for an Alteryx-solution to produce
The output:
A | B | AVG_A |
1 | 2 | avg_colA |
2 | 3 | avg_colA |
3 | 4 | avg_colA |
More precisely my problems are the following:
There is the Generate-Rows tool, which could create a such column AVG_A.
Then (using the record-id for example) I could join the column AVG_A with the Input table and obtain The output.
But for the Generate-Row tool I would need to know, the length of the original table.
Of course in the toy example the length is 3, but in a workflow it might vary.
Hence 2nd question: Is there a function, which determines the lenght of a table?
I see. there is a simpler solution to what you are trying to do. you are using the join tool as an append. That would require you to know the number of records to append all avg_A records to the original set.
instead of join, use the Append Fields tool where the original set is the "T" (target) and the summarized Avg_A stream is the "S" (Source).
I've attached an example workflow (in 2018.2 version).
Thanks again jarrod!