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

Alteryx designer Discussions

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

Multiple user inputs used in filter

Highlighted

Hi All,

 

Very new to Alteryx so patience is appreciated. What I am trying to accomplish is to allow a user to enter a set of words then filter a separate set of input data by those strings. For example - if one of the fields was names. I would like to allow the user to input Jack,Jim,Jess,Jane and have the output be filtered for only those names. I realize the below is far from working but just wanted to depict what I am trying to get at.

 

Any help for a new user would be appreciated!

Pulsar

Would something like this work for you?

 

Create a Text input with a placeholder set of names, then update this list from the Text box and Action tool. Convert the comma separated list to rows and use a join tool to grab the selected names from your input file. 

 

See workflow attached.

 

user input names.png

 

 

Pulsar
Pulsar

What David posted will indeed work just fine, but I thought I'd give another option, depending on what you want the user experience to be.


In this solution, the user enters their list of strings, one per line, no commas needed.  By default, it will be case insensitive.  

Here's my workflow:

zz_01.jpg

In the filter tool, have a custom filter of 1==1.  

 

Configure your Text Box tool like this:

zz_01.jpg

 

And your action tool like this:

zz_01.jpg

That formula is as follows:     '[cust_first_or_bus_name] IN ("'+REGEX_Replace([#1],'\n','","')+'")'

Thank you both for your replies.

 

MBarone - I attempted your method - however the filter doesn't seem to be actually working - all of the original data is passing through the filter unaltered

 

Can't really trouble shoot as I do not know how this filter is working. My workflow is the same as yours. Car Name is a column in the data set

Pulsar
Pulsar

Did you choose the multi-line feature on the text box tool?  And is the connection from the action tool to the filter tool named #1?

 

The filter tool, on the canvas, is just a place holder.  You could put anything in there you want, or even leave it blank.  For simplicity purposes, and so I don't have to look at a red exclamation point as I build, I put an "always true" statement like "1==1".

The action tool takes what's coming in and creates a formula for the filter tool to use.  When you use the multi-line option on the text box, whatever people enter will come in like this:

this

is

my

example

What you want to do is create a formula to stick in  your filter tool.

 

So you say okay, the formula to stick on the filter needs to be  [car name] IN ("this","is","my","example")

 

So we need to take:

this

is

my

example

 

And turn it into [car name] IN ("this","is","my","example")

 

Now, in the action tool, you're telling it to replace "1==1".  So you need to wrap what you're replacing it with in quotes.

 

The first step is to take

this

is

my

example

And make it look like ("this","is","my","example").

 

So you want to say "hey, start with the first word, and replace the carriage return with a comma, and oh yea, put quotes around each word", and then put what you come up with by doing that in parenthesis.  And then toss on a [car name] IN at the beginning.  To do this you need to use REGEX.  Carriage return in REGEX language is \n.   You also have to be careful with your quotes to make sure they get in there correctly.

 

So the formula for the action tool is: '[car name] IN ("'+REGEX_Replace([#1],'\n','","')+'")'

 

 

Make use of the debug feature - do CTL+ALT+D to open the interface designer, on the left, click the wand, enter some dummy values, then on the right click debug, and a module will open with your values inserted into the filter tool.  You can see there is any tweaks need to be made.

 

Unfortunately the community doesn't appear to allow me to post YXWZs, so I can't post a sample one.

Pulsar

@mbarone, if you export your YXWZ  as a package from Options -> Export Workflow, you'll be able to attach it to your post. I was wondering how you'd pass multi-line text into an argument of a filter tool with and action tool.

 

Nice work!

Pulsar
Pulsar

Thanks David!  And man, I feel dumb.  I knew about the exporting feature, but had total brain fog yesterday!!!

Labels