Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

Append to existing sheet if file exists and create file if it doesn't exist


Hello Experts,


I am looking for a way to create a new excel sheet if the file does not exist and append to existing file(also sheet) if the file is already present and write data to them .


For example,






We need to dynamically create a file called "test_exec. xlsx" if the flag is set as "0" and append to existing sheet if flag is set as "1"


Can somebody help me on this?


Thanks in advance :)


Hi there


Have a play around with this simple workflow I've attached.


If you have rows where the Flag = 0 and Flag = 1, you won't be able to output to the same Excel sheet at once.

Alteryx Certified Partner
Alteryx Certified Partner

Hello @jaimonsk ,


I recommend you to use 2 batch macros for that.


The first one would only accept the files flagged as 0. You pass as a parameter all the file names and data which would be written as new files


Do the same then for the second file but for the one flagged as 1, using this time an output but with the append property.


If you need an example for it let me know.


Kind regards




Hi @jaimonsk 


@afv2688 has a good solution, but you can accomplish the same result in a simple macros required. 




The Output tool on the top branch is configured to create the file if it doesn't exist.  The bottom one appends if the file does exist.  The directory browser read the files from the target directory and joins this with the list of filenames from the data.   Matches, which correspond to existing files, are routed to bottom output.  Non-matches go out the L output where the file is created.





This works great.Thank you so much