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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Pass in selected field value into sql

Hi,

Is it possible to select a field (loaded from inline) from listbox and pass the selection into my SQL script and automatically reload the data?

I know another way is to ask for input when reload the data:

Let vDate = Input('Enter Start Date (MM/DD/YYYY)' , 'Input required');

But this is not the requirement i want.

Thanks

6 Replies
ariel_klien
Specialist
Specialist

Hi

If I understood you correctly

You can try to use the function GetFieldSelections(),

Put it in a Variable and in the select:

Select *

From Data

Where Data.field = '$(vMyVariable)'

BR

Ariel

Not applicable
Author

Hi,

I tried the GetFieldSelections() function and encountered error when i reload my data.

Select *

From Data

Where Data.field = 'GetFieldSelections([Report Month])'

ariel_klien
Specialist
Specialist

Hi,

You need to put the function in a variable and in the select call the variable.

BR

Ariel

Not applicable
Author

ya. i did put the function in a variable. then in my sql, i use '$(vMonth)' but it show me that error.

luciancotea
Specialist
Specialist

GetFieldSelections() is an interface function, not script.

1. Add a variable (vSelectedValue) in "Settings" -> "Variable Overview" and assign it the following expression: =GetFieldSelections(myFieldName)

2. In script use: ... WHERE Data.field = '$(vSelectedValue)'

This will work only when you have only one selected value to pass on. If you want multiple values, you need to use a different expression.

Not applicable
Author

Hi,

Yeap, i know GetFieldSelections() is an interface function. However, i have to create a temp variable to assign the value to my variable.

Eg:

vTempSelectedValue = GetFieldSelections()

vSelectedValue = $(vTempSelectedValue)

So in my SQL, it will read vSelectedValue as my actual value instead of showing 'GetFieldSelections()' text.