Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Making ID based Macro dynamic

grandepaci
6 - Meteoroid

Hello everyone,

 

i created a macro that counts the max value of an existing "ID" Column and then continues to count up from the MAX Value.

The results will be saved in a new column. The NEW_ID Value is therefor the ID Value + MAX Value.

 

Now i want to make that macro dynamic to make it able to do that operation on diffrent column names for my "ID" column.

Do you have a proposal to make that possible?

 

Thanks

 

Sincerely Gabriel

 

grandepaci_0-1656332121526.png

grandepaci_1-1656332174897.png

 

 

7 REPLIES 7
IraWatt
17 - Castor
17 - Castor

Hey @grandepaci,

Would you be able to provide you macro file? I would suggest adding a control parameter to your macro making it a batch macro:

IraWatt_0-1656332738407.png

This would let you pass a list of columns to apply your logic too and then dynamically apply your macro to the data.

Any questions or issues please ask :)
HTH!
Ira

 

grandepaci
6 - Meteoroid

Hi Ira,

 

thanks for your answer. I added the 2 Interface Tools, and the List does now recognize another ID value.

 

Unfortunately it now only adds 1 to the NEW_ID column instead of counting from 444 upwards as it should in the macro.

Are there any settings i have to change in the macro?

grandepaci_0-1656402726421.png

 

Thanks in advance.

 

Sincerely

 

Gabriel

 

IraWatt
17 - Castor
17 - Castor

Hey @grandepaci,

Is this more along the lines of what your looking for:

IraWatt_0-1656404160812.png

Could you give an example input and output?

 

grazitti_sapna
17 - Castor

Hi @grandepaci, your macro is fine it is just you were grouping the fields based on the ID column which was giving you results based on each id passed.

grazitti_sapna_0-1656405721573.png

 

Also, in order to get the desired result as shown in the screenshot below you would need to add a summarize tool. to get the max_Id of the data passed outside the macro or it will multiply and create 9 iterations because you are appending the data inside the macro.

grazitti_sapna_1-1656405763998.png

 

Attaching the workflow along, in case of any issues please let us know.

 

Thanks!

 

 

Sapna Gupta
grandepaci
6 - Meteoroid

Hi again,

 

thanks for the explanation. I now understand the missing part in the macro.

 

The suggestion from @grazitti_sapna bring the right result. I also have reproduced that with a simple select infront of my macro. 

I wanted to create a dynamic macro, that doesnt need any further tools infront of it.

I was thinking of inculuding an expression into my macro, that is only referening the biggest value of all my ID's. Like an expression inside the macro that replaces the sumarize infront of it.

Is that even possible?

 

Sincerely 

 

Gabriel

grazitti_sapna
17 - Castor

@grandepaci, you can use a unique tool after the macro as the 9 rows are all duplicates which will give you unique result and you will not have to use any tool before macro input.

grazitti_sapna_0-1656498384853.png

 

I hope this helps!

Thanks!

Sapna Gupta
OllieClarke
15 - Aurora
15 - Aurora

Hi @grandepaci 

 

I think things might be being overcomplicated here. There's no need for batch macros.

With a macro input, you get the option to Show Field Map.

This will give users a drop down where they can assign a field to replace the one in the macro input.

If you connect the Q anchor of the macro input to an action tool, and then attach that action tool to a select tool before your macro output, you can 'Update Select with Reverse Field Map' which will rename the ID field back to whatever the field is called outside the macro:

OllieClarke_0-1656499999189.png

So in a workflow this looks like this:

OllieClarke_2-1656500131480.png

OllieClarke_3-1656500148819.png

 

Hope that helps,

 

Ollie

 

 

Labels