
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to: Loop & Reduce using a lightweight QVD generator app
Jul 4, 2023 8:56:10 AM
Jul 4, 2023 8:56:10 AM
This article explains how you can achieve Loop & Reduce functionality using a lightweight QVD generator app in combination with a Qlik Application Automation. The reduced QVDs that are generated are stored in different managed spaces. Empty apps are published to each of these managed spaces and then read the reduced QVD.
Automation flow
These illustrations have been cropped to only display two of the four managed spaces that are created using this example.
- The automation creates new managed spaces.
- The automation reloads the source app. This app acts as a QVD generator. The load script has been configured to read QVDs stored in the same shared space as the app and then store the reduced QVD files in the newly created managed spaces.
- The automation publishes empty apps to the managed spaces and then reloads them. The load scripts in the empty apps have been configured to read data from the reduced QVDs within the same managed space.
Resources
You will find the resources you need to run the automation example attached to this article.
Apps
QVD generator app
The 'QVD generator app' read the source QVDs stored in the same shared spaces as the app and then stores reduced QVDs into managed spaces per reduction field, in this case, region. The reduction and storage of these QVDs is done by running the load script of the QVD generator app. There’s no need for the QVD generator to contain any data, making it very lightweight. However, in this example, we do load some data for control purposes.
Empty app for reading reduced QVDs per space
The 'Empty app for reading reduced QVDs' per space has a load script that loads regional data into the app using relative paths. The automation publishes copies of this app into each managed space per reduction field. Upon reload, the reduced QVDs are read into these reduced apps.
QVD files
Source QVDs
This example comes with six QVD files:
- Categories.qvd
- Customers.qvd
- Order_Details.qvd
- Orders.qvd
- Products.qvd
- Regions.qvd
Reduced QVDs
Three reduced QVDs are created and stored in each of the managed spaces:
- Customers.qvd
- Order_Details.qvd
- Orders.qvd
Automation
The automation ('Loop & Reduce using a lightweight QVD generator app.json') orchestrates:
- The creation of managed spaces, if it doesn't already exist.
- Adding the automation owner as a member of the managed space with the role 'contributor'.
- Reload of the QVD generator app.
- Publishing empty apps in the managed spaces.
- Populating the empty apps with data read from the reduced QVDs.
More information on importing automations can be found here.
App & QVD configuration
- The 'Source QVDs' and the 'QVD generator app' must reside in the same shared space. When setting up this example, we recommend that you name this shared space 'Loop and Distribute QVD'.
- In this example, we also read data from non-reduced QVDs to the reduced apps. For this to work, you must ensure that the 'Global Data' section in the load script for 'Empty app for reading reduced QVDs per space' has the shared space specified, in which the source QVDs and the 'QVD generator app' is located. If you named the shared space 'Loop and Distribute QVD' you don't have to update the load script.
Running the automation
When running the automation you will be prompted to provide the following inputs:
- QVD generator app: specify the App ID.
- Empty app for reading reduced QVDs per space: specify the App ID.
- ReductionFields: Provide a comma-separated list of values that corresponds to the reduction values used in the QVD Generator App. In this case: Eastern,Northern,Southern,Western
Notes:
- Using a loop, the automation searches for existing managed spaces that match the provided values in the ReductionFields. If a space with a matching name exists, the automation owner is added as a member with the role 'contributor'.
- If there's no space matching the provided name, a new space is created and the automation owner is added as a member with the role 'contributor'.
- When all spaces exist, the 'QVD generator app' is reloaded to store reduced QVDs in each of the managed spaces.
- 'Space name' and 'Space ID ' for existing or created spaces are added to the variable SpaceObject, these are then stored in the variable SpacesList.
- A copy of the 'Empty app' is published to each of the managed spaces in the SpacesList by looping through the SpacesList. The name of the space is included in the name of the new reduced app and the Space ID is used to determine where to publish this app.
- Once an empty app has been published, it is reloaded so that it is populated with regional data from the reduced QVDs that reside in the same managed space. Global data is also read from Categories.qvd, Products.qvd, and Regions.qvd.
Potential improvements
- Instead of specifying app IDs and reduction fields, you could read these values from Microsoft Excel, or Google Sheets.
- Space memberships for users could also be assigned to spaces by reading the values from spreadsheets. For more information, see the article 'How to: Use Qlik Application Automation to manage space membership (users)'.
Environment
Qlik Application Automation
Qlik Cloud
The information in this article is provided as-is and to be used at own discretion. Depending on tool(s) used, customization(s), and/or other factors ongoing support on the solution below may not be provided by Qlik Support.