community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

Stop false part of a Filter from running

Meteoroid
I have a filter which sometimes results in True condition and sometimes in False. I want to stop the False part from running when the conidition is true and vice versa. What I have observed it that even when my conidtion is True, the tools in False part do run and result in error. Any way to get around this behavior?
Alteryx Certified Partner
Hi Pratik,

The way that I understand your request is that you want to:
  • Set a condition
  • If that condition is True then use the rows that are True.
  • If there are no rows that the condition is True for, then use the outputs of the False connector (the original data).
First, I'll explain how the filter tool is designed to be used. When a condition is set in the filter tool, that is executed per row of the data, the rows that the condition is True for, exit through the 'T' Output and the rows that the condition is False for, exit through the 'F' Output. So in that way, for most data you will get outputs on both sides.

This being said, you would need to somehow check whether there were any outputs of the True connector. You could do that with the following workflow. The way that this works is it:
  • Allocates a flag to the True outputs
  • Counts the True Records
  • Appends that
  • Checks whether there were True outputs and takes them if there were, otherwise takes the False Output.



If I've understood the question correctly, then this will work. (I'm assuming this isn't in a Macro or App, becasue otherwise you could use Condition or Detour tools)

Kane
Meteoroid
Hey Kane,

I tried the approach you suggested and it doesn't seem to be working. The way its currently setup is I have a field called itemCount - If that is 0 then I want to do a particular process (and just do that, nothing else). And if it is greater than 0 then do another set of task (and again, just need to do that). Now, what happens is even when my count is 0, although it does run the processes I need, it also runs the false part i.e. >0 (which actually has no rows) and results in an error in some tool because of missing data. I hope this makes it a bit more easy to understand.
Its like a simple If condition...if itemcount = 0 then do process 1 else do process 2 (but don't do both together).
Alteryx Certified Partner
Hi Pratik,

Firstly, I'm making the assumption that the field itemCount is equal for all records. If that is the case, then either all the records will go to True, or all to False... which is using the filter tool kind of like a detour, whereby, you can put a Union tool back in when the different processes have finished (I.e. if there are 3 tools that run for the True records, or 3 tools that run for the False records, then everything else is the same, then put a Union before the tools start that are the same), this will lessen the chance of a tool failing because there is no data. 

As a quick and dirty fix, you can also put a text input with one dummy row in and union that to the result to prevent the error...

Which tool is causing the error? How many tools are in each process? Are you able to post a screenshot of the workflow?
Highlighted
Meteoroid
Hi Kane,

Actually itemCount is an element in a XML which acts as a indicator telling me whether there are any records or not in the pipeline. If it is > 0 then I need to process those records and put it somewhere in my data warehouse, and if it is 0 then do nothing and just exit. I'm attaching the screenshot for your reference. What I don't understand is if there isn't any data in the false queue why the hell does it go ahead processing it.

btw, thanks for all the help you have tried to provide till now...it's a very inactive support community here...very difficult to find help for someone who is new to this tool :)
Alteryx Certified Partner
Hi Pratik,

It makes sense now as to what is happening. The tool is erroring because the Metadata is incorrect, this is a bit of a pain, and I'm not sure what the expected way to deal with this kind of an error is... however, I would cheat and just add in a dummy row using text input and union before that tool, then filter it out after. It's a workaround, but it's quick. And it can be replicated for any tools that are experiencing the same issue.

A more formal approach might be to either use a message tool or some combination involving the test tool. Ideally though, you would be able to use a detour tool after your false side, the issue is figuring out how to configure the action via a record count, and that is where it becomes interesting/confusing... and I think that your Macro may still show an error because the Metadata is not there...

Sorry I couldn't be of more help,
Kane
Quasar
Quasar

In the CReW Macros from @AdamR and his blog at http://www.chaosreignswithin.com/ there is an Ensure Fields macro that is most useful in these situations for ensuring that a field is present to prevent an error like this in a later tool.

 

You can download the macros from http://Downloads.ChaosReignsWithin.com/Macros.zip

Labels