Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
mikkeltaylor
Creator II
Creator II

Pass variable to script and reload data

Hi,

I have a summary table with a field for 'Test_no' e.g. 1,2,3,4,5,6,etc.  For each Test_No I have a database view e.g. vw_test_1, vw_test_2.  Each view can contain different fields.

My problem is I am trying to create the functionality for users to pick a Test_no (only 1 allowed) and then load/show the user the data for that test from the relevant view.

So far I have tried to load a view dynamically by writing "Select * From 'db.vw_test_'$(vTest)  by using LET vTest = only(Test_No): but that hasn't worked.

How do I get this syntax to work?  Should I be approaching this in a different way?

Thanks

Michael

5 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

No existing tables or fields will survive the restart of a load script (except when performing a partial reload).

You can create an input field tied to a variable, with a fixed set of possibilities to choose from (set them in the properties dialog). IMHO you can even make it into sort of a list box. Since a reload will not reset variables, that selection will survive in the variable and control your script to load just the view the user wants to see.

Peter

jagan
Luminary Alumni
Luminary Alumni

Let vCount = NoOfRecords('SummaryTableName');

For i= 1 to vCount

     LET vTableName = Peek('SummaryTableColumnName', i);

     If i=1 Then

          TableName:

          SELECT *

          FROm db.vw_test_'$(vTableName);

     Else

          Concatenate(TableName)

          SELECT *

          FROm db.vw_test_'$(vTableName);

     End IF    

Next

Hope this helps you.

Regards,

Jagan.

mikkeltaylor
Creator II
Creator II
Author

Thanks Peter.  I will look into your suggestion today and see how it pans out.  If a user reloads the data whilst another user is already viewing it would it cause issues with the first user? i.e. remove the data they are currently viewing?

mikkeltaylor
Creator II
Creator II
Author

Hi Jagan,  thanks for the response.  I'll try that code as it looks very promising.  Presumably it is designed to concatenate all of the data (views) together that the user has selected, rather than just one?

Peter_Cammaert
Partner - Champion III
Partner - Champion III

I think we have a bit of a misunderstanding here. My trick will work just fine for documents that are opened in the QlikView desktop, since an AccessPoint visitor is unable to reload a document.

If you plan to publish this document in your AP, then you'd better preload everything - possibly from a configurable table list like in Jagan's example - and let the user choose what view to display.

Or am I mistaken?

Peter