Skip to main content
Announcements
Qlik Cloud maintenance is scheduled for this weekend May 11-12. View maintenance windows per region here.

How to: Loop and reduce with always one selected value fields

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Emile_Koslowski
Employee
Employee

How to: Loop and reduce with always one selected value fields

Last Update:

Sep 29, 2022 3:29:02 AM

Updated By:

Emile_Koslowski

Created date:

Mar 14, 2022 5:17:20 AM

Attachments

Note: loop and reduce will remove an app's section access that was defined through the load script. Offline usage needs to be enabled in your tenant's management console in order to use the Loop And Reduce block on an app outside a personal space. More information on offline usage.

You might have noticed that it is not possible to perform a loop and reduce operation on apps that contain fields with the Always One Selected Value property set to true.

We've now released a new block, Set Always One Selected Value Field Property in Qlik Application Automation that allows you to manage this setting for individual fields.

The general idea is that you use this block to disable this property on all fields in the source app before executing the Loop And Reduce block. When the loop and reduce operation is completed, you can execute another instance of this block to set the Always One Selected Value property back to true.

 

Basic example

The following example is a practical application of this idea. The scenario is as follows: the source app has one field (Country) that has the Always One Selected Value property set to "true". This is also the field we want to reduce on during the loop and reduce operation.

Before you begin this example, make sure you have a basic loop and reduce automation that uses the blocks Loop And Reduce and Publish Reduced App To Managed Space. If you have no experience with these blocks, take a look at this article or get started with the "Loop, reduce and distribute an app" template that you can find in the automations template picker in Qlik Sense SaaS. In this article, we'll start with the following example:

Emile_Koslowski_0-1646754864167.png

Steps:

  1. Add the block Set Always One Selected Value Field Property before the Loop And Reduce block. Configure it to use the correct Field Name (Country in this example) and set the Always One Selected Value property to false.

    Emile_Koslowski_2-1646755123804.png

  2. Now add a Clear Selection block to make sure any leftover selections on this field are disabled.

    Emile_Koslowski_3-1646755191060.png

  3. Finally, add another Set Always One Selected Value Field Property block at the end of the automation to re-enable this property.

    Emile_Koslowski_4-1646755520604.png

 

That's it! We'll continue to build upon this automation in the next example were the source app contains multiple fields with the Always One Selected Value property set to true.

 

Re-enabling this for the reduced apps

In this example, the app has multiple (two) fields that have the Always One Selected Value property set to true: "Country" and "Year". We still want to reduce on Country as in the previous example, but we'll also have to disable this for the Year field before performing the loop and reduce operation. The reason for this is that the Year field will always have a selection applied which limits the amount of available data for the loop and reduce process. If we don't change this property for the Year field, all data that was not included in the selected Year before reduction, will not be available in the reduced apps.

We'll start this example where the previous example ended:

Emile_Koslowski_5-1646755966302.png

  1. The first thing to add here is a new Set Always One Selected Value Field Property block and a Clear Selection block for the Year field in the same way we did for the Country field in the first example. Tip: if you don't want your app to have any active selections before doing the Loop and Reduce operation, you can replace both Clear Selection blocks with one Clear All Selections block.

    Emile_Koslowski_7-1646756230134.png

  2. It makes no sense to re-enable this property for the Country field on the reduced & published apps since they'll only have one value available. But we do want to re-enable this for the Year field since that still has multiple values from before the reduction. To do this, add a Set Always One Selected Value Field Property block and a Save App block right after the Publish Reduced App To Managed Space block. And map the App Id fields of both blocks to the output from the Publish Reduced App To Managed Space block:

    Emile_Koslowski_0-1647248806085.png

  3. Finally, make sure to re-enable this for the Year field on the source app as well:

    Emile_Koslowski_2-1647249352687.png

 

Next steps

  • Note that during the loop and reduce process, the Set Always One Selected Value is disabled. It's possible that the app is used by someone else during the automation's run. If you think this is a risk or if you experience any issues with this, we suggest duplicating the app before performing the Loop And Reduce and removing the duplicate when the process has been completed.
  • You might have noticed that we've added the Save App block in the second example. You can find more information about this block in the following articles:

 

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.

Related Content

Labels (2)
Version history
Last update:
‎2022-09-29 03:29 AM
Updated by: