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

Dynamic Join using Batch Macro? Extremely Challenging (for me :))

byung0917
7 - Meteor

Experts!

 

I'm still struggling with what types of macro to use. 

I have two table I need to join. One table contains mapping logic while another table contains transactions. 

 

Logic table

Logic IDRegionCityFactoryProduct CategoryMapping Column01Mapping Column02Mapping Column03Mapping Column04
1WestSan FranciscoA*RegionCityFactory 
2WestIrvine**RegionCity  
3WestLos AngelesAXRegionCityFactoryProduct Category
4EastNew YorkA*RegionCityFactory 
5Central***Region   
6West***Region   
7East*A*RegionFactory  
8East***Region   

 

 

Transaction Table

 

Transaction IDRegionCityFactoryProduct CategoryAmount 
1WestLos AngelesAX100==> should be mapped with Logic 3 and 6
2WestOaklandBY200==> should be mapped with Logic 6
3EastNew YorkAX300==> should be mapped with Logic 4 ,7 and  8
4CentralChicagoAX400==> should be mapped with Logic 5
5EastBostonAX500==> should be mapped with Logic 7 and 8
6WestSan FranciscoAX600==> should be mapped with Logic 1 and 6

 

 

I've tried "Transpose" and "Crosstab" method and kinda figured it out. 

But, I would like to know whether it can be done using a macro. 

 

Do you have a good idea for this?

I'd really appreciate you experts' help and advice. 

 

Ideal method that I would love to try is feeding those mapping columns into a macro so the macro knows which columns to use for joining. 

Is this doable using a macro?

 

 

----------------

 

Thank you all for the responses. It has been a great help. 

Regarding the issue that I am facing with the solution below;

 

Logic IDRegionCityFactoryProduct Category
1WestIrvine*X

 

If I have transactions as below

Transaction IDRegionCityFactoryProduct CategoryAmount
1WestIrvineAX100
2WestIrvineBX200

 

The second transaction wouldn't be mapped with the logic since the cross tab will only pick up the Factory 'A' due to the "FIRST" setting in the crosstab. 

Thank you so much for your help!!!!

 

8 REPLIES 8
PhilipMannering
16 - Nebula
16 - Nebula

Interesting problem. I think I've done it....

PhilipMannering_0-1655934835502.png

 

Qiu
20 - Arcturus
20 - Arcturus

@PhilipMannering 
I can it is brilliant from the result.
but still in the process of figuring what is the logic of your macro.
And there is no Control Parameter Tool either in the macro.
I have to say, looking around the community and get involved with questions is a really good learning process. 😁

byung0917
7 - Meteor

@PhilipMannering Thank you for sharing the solution. 

This works with the sample I gave you but it seems it is not working when I work with the full dataset because of the "FIRST" setting on the Crosstab tool. "FIRST" makes the logic miss other values created for '*'. 

But still thank you so much for sharing your brilliant solution. 

PhilipMannering
16 - Nebula
16 - Nebula

@Qiu You only need a Control Parameter if you're trying to 'inject' values into the macro.

 

@byung0917 It would only miss values if the Logic ID is not unique. And if it isn't then you would need to add a RecordID and use that to group data in the Crosstab Tool. 

If you provide me an example of where it wouldn't work with the full data then I can amend the macro.

 

 

byung0917
7 - Meteor
 

@PhilipMannering Hi!!! Thank you for the continuous support on this! I've added a new sample at the bottom of the original post.  Thanks!!

PhilipMannering
16 - Nebula
16 - Nebula

@byung0917 So if you use the new inputs you get,

PhilipMannering_0-1655989507644.png

 

Is that not correct?

 

byung0917
7 - Meteor

@PhilipMannering Ah... I guess that was because I ran the data inside of the macro... It is very good that I got to learn this. Thank you so much!!!

PhilipMannering
16 - Nebula
16 - Nebula

Good stuff. Glad I could help.  ʘ‿ʘ

Labels