Git Product home page Git Product logo

Comments (12)

nabeel-oz avatar nabeel-oz commented on August 16, 2024

Hi @sagarkolte ,

Is there a reason you can't pass the list of selections with every SSE call? For e.g. store the list of selections in a Qlik variable and use that as one of the parameters for your SSE function calls.

However, what you have asked should be doable:

On the Qlik side you could have a variable that has a SSE function as the expression. This function should take in the list of selections as an argument.

On the Python side you then need an object that retains it's state during multiple SSE calls. One option is to extend the ExtensionService class in __main__.py with a variable to store your list.

If you are building a new class and define your SSE function as a @staticmethod, you will need to store your list in a class variable as any instance of the class will only exist during a single call.

And if you want the list to survive a restart of the SSE you'll need to save it to disk with something like joblib or pickle.

Hope that helps.

from qlik-py-tools.

sagarkolte avatar sagarkolte commented on August 16, 2024

Hi Nabeel,
Thanks, I have a (perhaps stupid) follow up question regarding the following part of your reply:

“This function should take in the list of selections as an argument.”

Can you please tell me how I store the selection of a drop down list into a variable?

Thanks and Regards

from qlik-py-tools.

nabeel-oz avatar nabeel-oz commented on August 16, 2024

It depends on what you mean by a drop down list. If you're referring to a standard listbox and want to get selections from a field, there are standard Qlik functions such as GetFieldSelections or Concat. You'll find more details on these at the Qlik Help site.

If you mean that you want a dropdown to control the value of a variable in your app, you would use an input control such as the Variable Input bundled extension.

from qlik-py-tools.

sagarkolte avatar sagarkolte commented on August 16, 2024

Thanks Nabeel, I will be trying this when I reach office. By the way, just for clarity’s sake to answer your question:

“Is there a reason you can't pass the list of selections with every SSE call?”

I can’t, as it takes 4 seconds for the function to run and I will end up making more than 400 calls to the function.

Regards

from qlik-py-tools.

nabeel-oz avatar nabeel-oz commented on August 16, 2024

Hi @sagarkolte , just curious if those are 400 unique SSE calls? Is each call being made with a different set of data or parameters? I ask because if it's just the same call being made by multiple users, Qlik will cache the results and avoid unnecessary computation.

from qlik-py-tools.

sagarkolte avatar sagarkolte commented on August 16, 2024

Hi Nabeel,
Indeed they are not. Each call is with the same set of parameters. But still it takes very long for the charts to finish rendering. Any idea why this might be? We are not on the latest version on Qliksense though.

Regards

from qlik-py-tools.

sagarkolte avatar sagarkolte commented on August 16, 2024

Hi Nabeel,
Actually thanks for being so helpful, I would like to take this opportunity to ask you your opinion on the following:

My python function accepts a list of strings and is supposed to return a table with two columns of type float. The intention here is for Qlik to plot a scatter plot using the two columns.

But apparently we cannot return a table to Qlik. So I converted that table into a json string and passed it to Qlik. I then use the Subfield and TextBetween functions to parse the json string and get back the float values.

Is there a better way to do this?

Thanks.

from qlik-py-tools.

nabeel-oz avatar nabeel-oz commented on August 16, 2024

On your first question of the charts would just be waiting for the SSE response so performance improvements can only be made on the Python side.

You can experiment with a single call and check that it is getting cached in Qlik. Make a set of selections and remove them, then make them again. The chart should render without a SSE call the second time. You can then add more calls and see if anything gets pushed out of the cache.

On your second question, you're right that currently a SSE can't return a table to a chart object (it can in the load script though). Usually this should not be a problem in the frontend as each SSE call is made through a measure or dimension which is a single column rather than a table. But if you need to return a table, the workaround is what you did; concatenate the values in Python in some way and the parse them in Qlik using SubField.

from qlik-py-tools.

sagarkolte avatar sagarkolte commented on August 16, 2024

Hi Nabeel,
Thanks. My response is in two parts:

  1. I tried making a single call and repeating the set of selections. The output from the function is not being cached. Is there a way to turn caching on?

  2. You say that the SSE can return a table in the load script, how does one do this? Could you please share a sample code which demonstrates this?

Thanks much!

from qlik-py-tools.

nabeel-oz avatar nabeel-oz commented on August 16, 2024
  1. Caching should be on by default, so you should think of any quirks of your app which might be stopping the expression from getting cached. There is a description of the caching mechanism and some examples at Qlik-OSS here.

  2. The LOAD ... EXTENSION syntax can be used to call a SSE from the load script as described here. Look at the 'Loading from analytic connections' example. For a working example you can refer to the Sample_App_Forecasting_Simple.qvf.

from qlik-py-tools.

sagarkolte avatar sagarkolte commented on August 16, 2024

Hi Nabeel,
Thanks so much for sharing the sample qvf. We realised that we were using excel sheets without natively importing them and that was causing the delay in getting the results. Somehow it was preventing the cache too. Everything is working fine now. However we would like to overcome this final challenge:

Using GetFieldSelection like function in the load editor. For example in your qvf file you have the vHospital variable. You seem to have saved a static value in this variable. We would like to store the user selection in this variable.

Thanks!

from qlik-py-tools.

sagarkolte avatar sagarkolte commented on August 16, 2024

Hi Nabeel,
I think this is the right time to close the issue as we have successfully overcome the challenges, thanks to your help.
Regards.

from qlik-py-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.