When I use a formula in Excel and don't have an exact formula to use or when it is burdensome to make a formula with bunch of functions many times, I go to VBA and make a user-defined functions.
It is really time-consuming to make a same formula over and over. Is there a way to make a user-defined function?
For example, if [field1] > [field2] then [field1]*[field2] elseif [field1] = [field2] then -1 else [field1]/[field2]
I want to define the above expression as a function, multiplyOrDivide([field1], [field2]). I have way too many columns to copy and paste the formula and change each argument in the parameters.
Solved! Go to Solution.
Hi @hlee36
There is a way to save expressions, maybe this helps? https://help.alteryx.com/10.6/SavedExpressions.htm
Yeah, that's what I've been using. When I load saved expression,
if [field1] > [field2] then [field1]*[field2] elseif [field1] = [field2] then -1 else [field1]/[field2]
Now, I have to change each argument 8 times in the above expression when I need to change the fields.
I was wondering if I can define the above expression as my own function, multiplyOrDivide([field1], [field2]) so I only have to change 2 arguments whenever I use the expression each time. This, I could do in Excel when I go to development tool where the VBA is. Not only it reduces the burden of changing columns, but it is easy to read and easy to maintain.
If there is no way to do in Alteryx, I think this is the part where Alteryx is inferior to Excel.
I appreciate your input, though.
Hi @hlee36
Gotcha, maybe this helps then? https://help.alteryx.com/developer-help/build-custom-formula-functions
Thanks, this is what I have been looking for.
I'm really glad this exists in Alteryx.
(Only found out my company blocked the directory of the folder for added function. lol. I will talk to my company to unblock it.)