Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

How to run the Alteryx workflow only if count of records is greater than 0

Ankita_ankita
5 - Atom

I have an Alteryx workflow which should run only if count of records is greater than 0. If there are no records then the workflow shouldn't run.

 

The workflow is like below :

 

sample workflow.jpg

22 REPLIES 22
DanielG
12 - Quasar

@Ankita_ankita -- i like to use the Test Tool and set it up to fail the workflow if no records come through.  see attached example

Deano478
12 - Quasar

hey @Ankita_ankita  you can try something like this using the message tool

 

 

Ankita_ankita
5 - Atom

Hi Daniel,

 

This doesn't work in my case. The test sheet still got overwritten. See workflow below :

 

Output.PNG

Towers
11 - Bolide

Hi @Ankita_ankita,

 

If you click on the canvas and go to runtime settings and activate the "Cancel Running Workflow On Error" box it should stop the file from outputting.

WorkflowError.jpg

You can see here that without the option ticked the records are written out:

Towers_0-1685714701466.png

But with the option ticked nothing is written out:

Towers_1-1685714718859.png

Your current configuration should work as long as you turn this setting on.

 

danilang
19 - Altair
19 - Altair

Hi @Ankita_ankita 

 

@DanielG's example will work(most of the time) but you need to have your workflow config set to Cancel running Workflow on Error, which was missing from TestExample.yxmd 

danilang_0-1685715475365.png

 

A more generic way, or one to use when you want the workflow to complete even if some of the outputs are empty, is use a formula tool to create a path and use this path in the Output Tool

 

danilang_1-1685715774776.png

danilang_2-1685715823358.png

Since there are no records going into the Output tool, there is no FilePath field for it to use.  The end result is the target file does not get changed.

 

Dan 

 

   

 

 

 

 

DanielG
12 - Quasar

@danilang - darn it.  I am better than that.  I forgot the most important aspect of it.  Thanks for catching it.  haha.  Have a great day

Suppu
7 - Meteor

I have done the configuration also but its still overwriting the file at the end with 0 records whihc I want to stop .
Please suggest.

DanielG
12 - Quasar

@Suppu - Can you add a block until done that connects first to a test tool.  If record count is 0 you can have the workflow "fail" and stop before it gets to the 2nd path out of the block until done which would be the output.

Suppu
7 - Meteor

@DanielG 
Please see the attached image of my workflow and suggest . Here the Test_OP file still gets overwritten.

Labels
Top Solution Authors