Looking for the best way to prompt for specific field/column. For example, if I have a column that has a month in it, I would like be prompted to enter a month that would then filter those results, or add several prompts to be used in filters.
Solved! Go to Solution.
There are a bunch of different ways to accomplish anything in Alteryx. That flexibility is awesome, butcan be a bit overwhelming if you're trying to optimize a large workflow. The best general advice I could give you is to experiment and learn in an iterative way. That said, here's three ways to accomplish your goal, each a slight twist on the others. Whether one way or another is 'better' is going to depend on the specific circumstances and what you need to do. Even the 'bad' way is still going to work most of the time, just not as well as the 'better' way might.
These involve building a macro, and if you haven't built one before, you may want to review some of the video lectures or other forum posts to get a little more comfortable with the concept.
Method one: Simple filter
First, setup a Filter tool and give it some default value (which it will only use when you are inside the macro, but should be "real" to enable your macro testing to work). Add a Textbox interface tool and connect it to the lightning input on the filter node to automatically create an Action tool. We're going to configure the action tool to update the value, then we click through the expandable list until we find the value we wish to replace (in this case the placeholder month 'May'). The Action tool will update that default value of 'May' at runtime.
Second Method: Dropdown
In this method, we will use the Drop Down interface tool and specify a list of values from which the user can select. Because we specify the user's choices, we don't have to rely on them spelling anything correctly. When you use the "Manually set values" option in the dropdown tool, you do not need to specify both the Name and Value if it is the same (if we wanted to convert from word month to number month, we could do it by writing in the format "January:0" etc.). The Action tool should be configured the same as we did in method one.
Method Three: Switch statement
In this example, I've used the Action tool's "Update value with formula" rather than the default "Update Value (default)" option so I can add some logic via a simple Switch (CASE statement for those from other programming languages). With the Switch statement formula, we're asking it to take the value from the textbox, signified by its connection to the action tool ([#1] in this case), and look for the numbers 1, 2, or 3, and replace it with the respective month name. If the textbox doesn't contain one of those numbers, return "ERROR" (which is not a month, so when it replaces "May" in the filter, no data will come through but no error will actually be created). This is useful if you need to convert hardcoded values from one system into another. It offers some additional protection over Method One against user error, but less than Method Two.
Hope this helps :)
@david_fetters provides 3 great ways to use Interface tools to change a Filter tool via a prompt! Just to clarify his solution: the 3 methods are actually examples creating an "analytic app", not necessarily a "macro". Macros can be dragged onto the canvas and be used like other tools; your prompt would be seen in the macro's configuration. Apps actually have a "wizard" or user-interface component; once you add an Interface tool like the Text Box, Action, or Drop Down (but not the Macro Input, Macro Output, or Control Parameter), you should see a small magic wand near the Run button at the top of the Designer...click that and your prompt will appear.
To help you get started with app building, I'd recommend watching the "Introduction to Building Applications" Virtual Training video by Alteryx here: http://www.alteryx.com/virtual-training/ (click Watch a Past Session). Hope this helps! :)
Can you please help me as I am struggling to get method two of your reply to work?
I have a text Input that holds data for the months of the year (201701, 201702, 201703 etc). I would like to have a drop down box (also containing 201701, 201702, 201703 etc) to be used by an action that is applied to a filter on the text Input table.
For example I would like to pick 201703 in the drop down list and have 201703 appear as the only value in the TRUE output of the filter.
Every time I run the workflow I have written I receive the following message "There Were No Output Files".
Any help would be greatly appreciated.
Error may not necessarily mean there was no output generated... you just need to indicate in the app configuration that you want to actually see the results (i.e. in a Browse tool) when the app is done running.
Go to View > Interface Designer (or hit Ctrl + Alt + D). In the Interface Designer window, click on the wrench icon and then in the "On Success" box, indicate which Browse tools you want to show after a successful run (or a link to the files that were output, etc.) That should show you the results from your app when run!
Cheers,
NJ
Thanks Nicole
This have fixed the problem I was having.
:-) Great to hear @Tristan_Camplin
Would you mind marking this thread as solved using the green "Solution" button so that this can be added to the knowledge base?
Have a great Thursday
Sean
Hi David,
All the solutions proposed by you bring in the entire data and then filter on it. I need to filter the data before hand i.e run the query only for 2 months selected by user. Is it possible using textbox?