We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

File2 has a different number of fields than the 1st file in the set and will be skipped

Rajinikanth
6 - Meteoroid

Hi, 

 

Thanks in Advance!

 

I'm new to Alteryx and I'm trying to load multiple files having different schema to multiple SQL tables using batch macro & dynamic input. But only 1 file is read and other files are skipped.

 

Example : I have 2 files "File1" & "File2" and these 2 files should be loaded to 2 different SQL tables when i give the folder path to directory tool.

 

File 1:

SNONameDesignation
1MarkManager
2TimSenior
3JonStaff

 

File 2: 

SNONameDepartmentPay
1Mark1ABCXX
2Tim1XYZXY
3Jhon1ADFXZ

 

Method i used is :

 
 

BatchMacro.PNG

Calling Macro.PNG

 

 

Can anyone help in getting this done. With an example. 

 

Thanks!

 

6 REPLIES 6
randreag
11 - Bolide

hi @Rajinikanth 

 

If you use dynamic input for this , you are always going to have problems with the fields

 

You need to receive in the macro the file name, without using the dynamic input, in the same macro you can add a insert in to the table, sending the name dynamically

 

i hope it helps

 

Let me know if you have more questions

 

Rajinikanth
6 - Meteoroid

Thank you !

I now removed dynamic input tool and now the different schema issue is not shown, but when i load data to SQL tables. Both the tables have columns from both the files. But it the table should ideally have column names that are present in the source input file.

Calling Macro_1.PNG

 

Example : Output table has fields as below,

 

Table1 : 

SNONameDesignationDepartmentPay

 

Table2:

SNONameDesignationDepartmentPay

 

Note : Fields names related to other file is populated will nulls.

 

But the output table should have fields exactly as the source file.

Can you please help on this.

 

Thanks!

randreag
11 - Bolide

Hi @Rajinikanth 

 

You send the files with the same names, I guess some are different.

 

I this a batch macro? Do you have configured in the interfaz designer this options?

 

aruiz-itp_0-1611852503250.png

try first configuring this. If doesnt work you can do the following:

 

 

So I will send to the macro the list of fields, maybe separated with coma.

Inside the macro I will separe it , compare it with the ones that are in the file (maybe with transpose or field info) and assingn it with dynamic rename or using dynamic select

 

Just some ideas hehe, perhaps it would need less steps 

Rajinikanth
6 - Meteoroid

Thank you Soo much for the quick response. I haven't selected the option "output fields change based on input configuration". But now I updated the batch macro configuration below is the screenshot for same. But still the output is same. Field names are coming form both the files.

 

BM_Config.PNG

 

Can u please share me a sample workflow on how to get only the source file fields in the output table.

 

Thanks!

JagdeeshN
12 - Quasar
12 - Quasar

@Rajinikanth 

 

Please find attached a sample workflow to achieve what you described. This process creates yxdb files in the output folder as outputs. This can always be replaced with a database write within the macro.

 

Let me know if this helps.

 

Best,

Jagdeesh

Rajinikanth
6 - Meteoroid

I Changed the Macro WF by adding "Output tool" directly in macro instead of Macro out and Called this Macro in the Main WF which solved the issue.

 

Rajinikanth_1-1611858610915.png

 

 

 

Thanks!

Labels
Top Solution Authors