Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

How to: If file exists, overwrite file. If file doesn't exist, create new sheet.

Jes
8 - Asteroid

I have multiple workflows that can be run multiple times throughout the day, triggered manually by a user.

 

In the workflow, there is a single output where:

1. If this is the first time the workflow is being run, it will create a new excel file with a pre-specified sheet name that contains today's date.

2. If the workflow is run twice in the same day, I'd like to data to go into an output tool that is set up to Overwrite file.

 

Is there a way to create a conditional workflow so that if a file doesn't exist, the data flows through to the output tool that is set to create a new worksheet. If the file already exists, the data flows through to the output tool that is set to overwrite file?

 

 

6 REPLIES 6
ImadZidan
12 - Quasar

Hello @Jes ,

 

I hope I understood your request.

 

Check the workflow. I have not tested.

 

At least it will give u an idea

AngelosPachis
16 - Nebula

Hi @Jes ,

 

A single output tool can be configured in a way so it creates an output file if the file does not exist, or replaces said output if the file exists already. To do that, in your output tool change option number 3 to overwrite the file

 

AngelosPachis_1-1613857129694.png

 

 

Now, to dynamically change the file name/sheet name, you have to use a formula tool before your output to create the exact file path you want your file saved.

 

In the below expression, I have used .\ at the beginning to make the output file be saved exactly in the same location where the workflow is saved, but you can go on and change that to 

 

"C:\Users\YourUsername\File1\Project1\Outputs"

 

or whatever works for you.

 

AngelosPachis_2-1613857219969.png

 

Then you can replace the name of the file from Output- to something else, but make sure you keep the Datetimetoday functions so they can assign the date that the workflow is run.

 

Hope that helps, let me know if that worked for you.

 

Regards,

 

Angelos

 

Jes
8 - Asteroid

@ImadZidan 

In your existing workflow, how would I introduce the data that I am looking to output?

Below is the tail end of my workflow where the formula tool identifies the folder directory & date stamp. This then flows into 2 Output tools: 1 set up to create sheet, 1 set up to overwrite sheet.

 

I am looking for a conditional data flow

JH0123_0-1614005144731.png

 

Jes
8 - Asteroid

This ended up working

2021-02-22_10-04-13.jpg

ImadZidan
12 - Quasar

Hello @Jes , 

 

Brilliant, you got it to work. If you want to build a workflow around this logic, let us do it.

 

Imad

 

Labels