Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Sheri
Contributor II
Contributor II

Query Prompt

Can I have a prompt to filter the data when using an SQL query? Something like: 

Select * from table where column = prompt

--- where "prompt" is input from the user at run time

 

Labels (1)
1 Solution

Accepted Solutions
igoralcantara
Partner Ambassador/MVP
Partner Ambassador/MVP

Remove the Set line, it will override the value set on the UI.

Check out my latest posts at datavoyagers.net

View solution in original post

11 Replies
igoralcantara
Partner Ambassador/MVP
Partner Ambassador/MVP

Good day. Where are you planning to do this? Qlik Sense load script? Somewhere else?

Check out my latest posts at datavoyagers.net
Sheri
Contributor II
Contributor II
Author

Yes in the Qlik Sense Load script. I would like my report to prompt the user and then use that result to run the query for that filter.

igoralcantara
Partner Ambassador/MVP
Partner Ambassador/MVP

You can do something similar using variables.

Option 1: Easy

Set a variable in your script and use it as a prompt 

Set vPrompt = value;

Select * from table where column = ‘$(vPrompt)’;

 

Option 2: Less easy

Set the variable using a input variable custom object. Have a button that reloads the app.

Check out my latest posts at datavoyagers.net
Sheri
Contributor II
Contributor II
Author

How does the first option prompt the user?
and if it does not, do you have the steps to do the second option?

 

igoralcantara
Partner Ambassador/MVP
Partner Ambassador/MVP

To prompt the user you need the option 2.

Check out my latest posts at datavoyagers.net
Sheri
Contributor II
Contributor II
Author

I am trying to do option 2, but it is not working. Do you have the steps? Or a video that shows me how?

igoralcantara
Partner Ambassador/MVP
Partner Ambassador/MVP

Sure. Here are some images that show the sequence.

In summary, you need to (after your script is ready to use the variable as my earlier message showed):

All in the sheet design mode.

- Create the variable

- Add an Input variable object and configure it

- Add a button 

- Add a Reload action to the button

Check out my latest posts at datavoyagers.net
Sheri
Contributor II
Contributor II
Author

That is what I tried before. It does not pass the value (that the user put in the variable) to the query to fetch the data using the prompt value. It just reloads the data using the value that I set in the original query.

This would be my original query on the firs load.

Set vPrompt = 4845;

Select * from table where column = $(vPrompt);

Once the user typed in the Variable Input input box the value of 4851 and presses the button. The page reloads with the 4845 value. I need it to use the 4851 in the query and go get the data for that value.

igoralcantara
Partner Ambassador/MVP
Partner Ambassador/MVP

Remove the Set line, it will override the value set on the UI.

Check out my latest posts at datavoyagers.net