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

Anonymising multiple string fields using batch macro

cgoodman3
14 - Magnetar
14 - Magnetar

I am trying to build a batch macro where I can mask multiple string fields in one batch macro.

 

If as an example my input data looks like:

Sample Input Data.JPG

I want to get to a position when the Company and SalesPerson string fields are masked to be as follows (with the field name becoming the prefix).

Sample Output Data.JPG

I've built my macro, but the output I get is like this:

Actual output.JPG

 

So the macro seems to be running through twice and unioning the results, but what I want it to actually do is iterate over the input and take the input after the first pass through (i.e. "Company" being passed to the control parameter) to become the input for the second pass through (when "SalesPerson" is passed to the control parameter).

Untitled.jpg

I can get it to work by putting the same macro in twice and passing to the 1st control parameter "Company" and the second macro "SalesPerson", but for the real dataset I'm trying to do this to, it has many fields and so I've just put two in to explain the issue. I feel like I'm close and it might be just a configuration setting that needs adjusting, so any help appreciated.

 

 

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
7 REPLIES 7
Claje
14 - Magnetar

Hi,


Your macro didn't seem to come attached to this process.


However, I'm curious if we can't come up with a solution that doesn't require a macro.

 

I attached a workflow which I think accomplishes what you are looking for without a macro, and also includes some randomization of element order so that company/salesperson's get different ID's each execution.

 

Let me know if this helps!

jdunkerley79
ACE Emeritus
ACE Emeritus

Like @Claje - think this is best done without a batch macro.

 

2018-11-09_22-14-12.png

 

For each field create a masked value for every unique value and then put back in place of the original with a join

 

 

cgoodman3
14 - Magnetar
14 - Magnetar

[Duplicate]

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
cgoodman3
14 - Magnetar
14 - Magnetar

Awesome both! I'd been racking my brains for over an hour trying to solve and the community comes back with two solutions in almost as many minutes!

 

I think I was going down the macro route as I want it to be a tool to just drop in to any workflow, but seems like that's caused me to end up in the rabbit hole! 

 

Is there a more dynamic way of updating the order in the last join to match the column order of the input. I'm just thinking when the number of fields to mask get large getting the right order will be a pain?

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
jdunkerley79
ACE Emeritus
ACE Emeritus

@Claje challenge me on the same thing.

 

This package has a dynamic join in the middle of it. It basically matches fields by name and replaces. It does this using an internal batch macro and configuring it by a wrapper macro.

 

The result is the fields to be masked are selected in the transpose and just flows through

 

2018-11-09_22-59-45.png

cgoodman3
14 - Magnetar
14 - Magnetar

Thanks James for this. I really liked the approach to changing the XML.

 

Having shown your solution of the macro to ensure the column order remains after anonymising to a colleague (@nikolaskardsis), we've come up with this solution which doesn't require dynamically changing the XML.

 

Proposed alternative solution:

By putting the masked part of the workflow as the left input to the join, and the original data as the right input, then deselecting duplicate fields and record ID (this will keep the new masked fields and remove the original ones), then by unioning the data with the original headers results in reordering the fields back to the original order.

 

Capture.JPG

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
jdunkerley79
ACE Emeritus
ACE Emeritus

Nice.

 

2018-11-12_11-15-50.png

 

I adjusted a little and packaged up as a macro with a UI on it. I use a dynamic select to lose the duplicate fields now.

 

 

 

 

Labels