I'm fairly new to Alteryx and i'm trying to fix something simple. i have a column in which there are values ranging from 1-5. i simply want to reverse them, as in replace the 1s with 5s, 2s with 4s and so on and so forth. How do i do this?
Current Column |
1 |
2 |
4 |
4 |
5 |
5 |
3 |
Desired Column |
5 |
4 |
2 |
2 |
1 |
1 |
3 |
Solved! Go to Solution.
I would use the Table Tool to create a table like this:
Old Value | New Value |
1 | 5 |
2 | 4 |
3 | 3 |
4 | 2 |
5 | 1 |
Then join to your data using "Old Value" as the join field and use the "New Value" column to continue with your workflow.
ThizViz, do you mean this could be accomplished using the text input tool?
Hi SimJB
The solution from @ThizViz will work, but a more generic one would be to find the maximum of the values in the [Current column] and then use a formula to compute the values in the [Desired Column]. This will work with any number and range of values, without having to build the lookup table manually
Dan
This is great, thanks! Right after I posted this query, I stumbled upon the switch tool and it worked, although the suggestions I received on this thread are far more elegant. I have another task at hand where I have to replace numeric values in a column with string values. It will essentially work in the same manner, where there are two tables. 1 will be replaced with Africa, 2 will be replaced with Americas and so on and so forth. I think the solution you provided should work in this situation as well. Is it possible to show this as an alteryx workflow, it would be super helpful. Thanks!
Yes, that's what I meant, sorry.