Skip to main content

Official Support Articles

Search or browse our knowledge base to find answers to your questions ranging from account questions to troubleshooting error messages. The content is curated and updated by our global Support team

Announcements
Qlik Cloud Maintenance is scheduled between March 27-30. Visit Qlik Cloud Status page for more details.

Getting Started with Advanced Analytics in Qlik Sense using Python

cancel
Showing results for 
Search instead for 
Did you mean: 
Sonja_Bauernfeind
Digital Support
Digital Support

Getting Started with Advanced Analytics in Qlik Sense using Python

Attachments


This is a basic example in order to get started with Advanced Analytics Integration in Qlik Sense using PYTHON.

The architecture at a high-level looks like this:

User-added image

With this new capability, it is possible to add syntax to a chart expression that tells Qlik Sense that particular expression should not be evaluated on the Qlik Sense server, but instead, all the information and data needed to calculate that expression should be sent via the server side extension on to the back end Python system for calculation.

 After the advanced analytic calculations are completed, the data is sent back to the Qlik Sense Server and to the client for visualization.

For an example with video that uses R-Server instead, see R Integration with Qlik Sense 

Environment:

 

Resolution:


In order to display a "Hello World" message in the Qlik Sense App, Perform the steps below:

Note: To obtain the latest HelloWorld example and other Python examples, see Python Examples in Qlik's Github repository. Make sure to check out the GetStarted.md documentation as well.
 

  1. Make sure you have Python 3.4 (or later) installed including 'PIP' option. Run python -m pip install --upgrade pip to upgrade to latest version of pip.
  2. Install the grpcio package. In order to install it, use: python -m pip install grpcio
  3. Install the numpy package. In order to install it, use: python -m pip install numpy
  4. Install the nose package. In order to install it, use: python -m pip install nose
  5. Install the pandas package. In order to install it, use: python -m pip install pandas
  6. Install the google package. Use python -m pip install google
  7. Install the protobuf package. Use python -m pip install protobuf
  8. May need to install the google API Python package on older examples: If so, use pip install --upgrade google-api-python-client
  9. Note: If using Qlik Sense Desktop, add SSEPlugin=<EngineName>,localhost:<port> on a new line in your Settings.ini file located at C:\Users\[user]\Qlik\Sense. For example: SSEPlugin=SSEPython,localhost:50052
  10. Note: If using Qlik Sense Server, Create an Analytic Connection. See Creating an analytic connection
  11. Create a Qlik Sense app with basic data. In the app attached to this article Inline Load of 2 strings was used. Alternatively, use the HelloWorld example app included with the Server-Side Extension (SSE) package that can be downloaded in .zip format under Qlik SSE. 
  12. Note: See example app attached. Create a new KPI object in a Sheet. Under Measures, add: SSEPython.ScriptAggrStr('", ".join(args[0])' , HelloWorldData)
  13. A Plugin using Python needs to be written so that you can communicate between Sense & Python engine using gRPC. See attached the example written using the open-source plugin provided by Qlik in order to test this functionality. Please note that these plugins are open-source and support will not be provided for it by Qlik Support (refer to the T&C in Writting an SSE Plugin
  14. Run the plugin in CMD prompt, using command: python ExtensionService_helloworld.py  Note: Troubleshoot ModuleNotFoundError
  15. You will be presented with this screen -

                      User-added image

9. Now restart Qlik Sense desktop & open your Sense app.
10. You should the below object utilizing Python -

User-added image

Understanding the Python script & Function:

 

 

 

 

SSEPython.ScriptAggrStr('", ".join(args[0])' , HelloWorldData)

 

 

 

 


Eight script functions are automatically added to the functionality of the plugin. What is needed to be covered on the plugin side to fulfill
the functionality is to implement the Script aggregate rpc function.

The syntax of these functions is <EngineSSEName>.<FunctionName>(Script [,Parameter...])
where the Script is a Python script to be evaluated & Parameter is the data sent from Qlik's end.

Here, the ScriptAggrStr function is used which accepts argument of type String & returns a String after an aggregation. The 'join' function in Python method returns a string, which is the concatenation of the strings in the sequence seq. The separator between elements is the string providing this method. From Qlik side, we pass a field called HelloWorldData which contains the 2 strings as we have loaded.

To use SSE function(s) to load data via application load script, the Extension clause needs to be used. See additional information as well as an example under Load > Argument > Extension and Examples > Loading from Analytic connections via the following link: Script Regular Statements: Load.

 

Related Content:

Version history
Last update:
‎2021-02-23 04:12 AM
Updated by: