Alteryx Designer Desktop Discussions

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

Trying to take input from user to use it as parameter in my query

mertmetinn
6 - Meteoroid

Hi everyone,

 

I am trying to use an analytic app in Alteryx to take input value from the user to use in the query as an input.

 

For eg:

 

SELECT * FROM dbo.Mega

WHERE CAMPAIGN LIKE "%x%"

 

I want to take this x value from the user and then use it in the query instead of x.

 

How can I do that? any video, sources, articles? 

 

Regards, 

 

4 REPLIES 4
cpet13
10 - Fireball

@mertmetinn  I'm not sure you can edit the SQL statement in the input tool. What you could do, however, is not have that WHERE statement in the query, just do select *, then have a filter tool down the road that you setup a n interface tool that lets the users choose what to filter on. Here's a document on Alteryx Interface tools: Understanding Interface Tools (alteryx.com).

DataNath
17 - Castor

Hey @mertmetinn, I'd do this with a Text Box interface tool and Action tool linked to your Input Data tool. Here's a quick example:

 

1) Set an initial template query. In your case this is:

 

SELECT * FROM dbo.Mega

WHERE CAMPAIGN LIKE "%x%"

 

In my example:

 

UpdateWhere1.png

 

2) Link a Text Box tool to your Input Data tool - an Action tool will appear automatically between. In the configuration, find the 'Query - ' line under FormatSpecificOptions and click on this. Tick the 'Replace a specific string' box below and reduce this so it's only the text you want to replace - in your scenario, 'x'. In mine, this is 'Day 10'.

 

UpdateWhere2.png

 

Note: I'd recommend using something a lot more explicit than 'x' here - as you're replacing the string with the user's input, this will replace any instance of that. Therefore, if you have any other 'x' characters in your query, they'll get replaced with the user-provided value. I normally use a very specific placeholder like <DummyValue> and use that as the replacement target.

 

3) When I run the workflow as an app and enter something different i.e. 'Day 15' in this case, this replaces the template value in my query and returns Day 15 values as you can see in the Browse output window:

 

UpdateWhere3.png

 

Hope this helps! Feel free to shout if you need any additional help.

Qiu
21 - Polaris
21 - Polaris

@DataNath 
Really nice, detailed answer. 👍

mertmetinn
6 - Meteoroid

Really great explanation, thank you so much, it definitely worked on my workflow, now trying to understand fuzzy match module and its custom configuration, can I ask some more questions about it ?

 

Regards,

 

Mert

Labels