Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Optional Input for App

ckestler
8 - Asteroid

Hello,

 

I am trying to create an App which queries from a database, and takes multiple inputs using the Text Box and Action tools. But, I don't always want the query using all of the action tools..I want some of them to be optional. 

 

For example, I would like to possibly only enter the Div ID (see attached), leave the other fields blank, and have the query just execute on div id. Is this possible?

3 REPLIES 3
nick_schimweg
8 - Asteroid

In a macro (should work for your app) you could use a nested if statement and a single action tool utilizing the 'update value with fomula' function. You would have the action update the SQL statement.

 

Something like:

 

IF [Div ID] > '' AND [Model Request ID] > '' AND [Model ID] > '' AND [Selection Request ID] > '' AND [Campaign ID] > '' THEN " 'Div ID = '[Div ID] +' AND '+ 'Model Request ID = '+[Model Request ID]+' AND 'Model ID = '+[Model ID]+' AND '+'Selection Request ID = '+[Selection Request ID]+' AND '+'Campaign ID = '+[Campaign ID]" ELSE

IF 

ISEMPTY([Div ID]) AND [Model Request ID] > '' AND [Model ID] > '' AND [Selection Request ID] > '' AND [Campaign ID] > '' THEN "'Model Request ID = '+[Model Request ID]+' AND 'Model ID = '+[Model ID]+' AND '+'Selection Request ID = '+[Selection Request ID]+' AND '+'Campaign ID = '+[Campaign ID]" ELSE

 

etc..

 

One if statement for every possible selection.

 

 

Hopefully someone will chime in with a cleaner way to do it.

KaneG
Alteryx Alumni (Retired)

Hi @ckestler,

 

You can nest the interface tools under a checkbox or radio button as such:

 

Image 001 - 20161101 - 131139.png

 

Tick the option on the Checkbox/Radio Button for 'Collapse Group when Deselected' and use the up/Down arrows in the interface designer to nest the options inside the selectable options.

 

Kane

David-Carnes
12 - Quasar

OK, a little late to the party.  Was Googling for a different problem and this  appeared in  the results.  Anyway...,

 

A good technique is to create your base SQL statement and have a where 1= 1 clause.  After that, just append as many "and this = that" clauses that your users choose.    Example:

 

Base_SQL  = "select greeting1, greeting2 from salutations where 1 = 1"

 

Then you can append  "and greeting1 = 'hello'" and/or  "and greeting2 = 'world'" depending on if your user filled in either one or both.

 

I know in the Dynamic Input tool you can replace the whole SQL statement, so build up your SQL  with the  additions to the where clause and run with it.

Labels