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

Multi-Field Tool with dynamic fieldnames in formula expression

SP
5 - Atom

Hi All,

 

I am wondering whether there is an elegant solution to the following problem.

Example data:

v1, v1faktor,

v2, v2faktor,

v3, v3faktor, ...

 

Following data should be the output:

v1new = v1 * v1faktor,

v2new = v2 * v2faktor,

v3new = v3 * v3faktor, ...

 

I tried the multi-field tool with v1, v2, v3 as input, but struggled to modifiy the field name in the expression to work dynamically.

Is it possible to make an expression similar to [_CurrentField_] * '['+'[_CurrentFieldName_]'+'faktor]'

 

Thanks for any help in advance!

 

Sabine

7 REPLIES 7
dataMack
12 - Quasar

I think a standard formula tool would work best in this situation since you want to create a single new field that is the product of two other fields.

 

The multi-field formula tool is useful if you want to apply an operation across many fields at once and only specify the formula once.  For example, let's say i have 20 fields of numeric cost data in a foreign currency and I want to multiple all of them by the same factor to convert all 20 to my domestic currency- that's where the multi-field formula tool would be handy.

 

 

SP
5 - Atom

Thanks for your answer.

In fact I do have sets of e.g. 10 (sometimes more) variables v1, v2, ..., v10 which I have to process in several steps, each time resulting in 10 new variables v1_new, v2_new, ..., v10_new. Usually the Multi-Field tool works pretty good for this. But in some cases I need to include in the calculation of the new variables other corresponding variables like v1_faktor, v2_faktor, ... v10_faktor.

Currently I use the normal formula tool typing the same formula (v1_new = v1 * v1_faktor) 10 times. But I'm sure there must be a better and more fail-safe way to do this.

DataBlender
11 - Bolide

Hi @SP, I'd suggest taking a look at the dynamic formula macro from CReW:

 

http://www.chaosreignswithin.com/2013/11/dynamic-formula-macro.html

SP
5 - Atom
 
SP
5 - Atom

Thanks @DataBlender and @AdamR, this should work fine for me!

I will definitely go and have a look and those other useful CReW stuff... :)

rickydata
6 - Meteoroid

Did this work? I'm a bit cautious downloading non approve Alteryx macros.  

flying008
14 - Magnetar

Hi,@rickydata 

 

Don't worry about it.

 

录制_2022_11_09_10_16_27_374.gif

Labels