Posted on: 25th June 2020, 11:59 am
This is a follow-up article to my recent post about Section Access in Qlik Sense: Row and Column level security in Qlik Sense using Section Access. In this post I’m going to talk about how to handle Incomplete Visualisation errors that are caused by omitted fields in your security table.
When building your Qlik Sense applications, you may be required to hide sensitive information from specific users. In Qlik Sense this is controlled by a security table, in the form of section access. As well as row level security, administrators can also hide entire fields (applying column-level security). When a field is omitted from a user, but is still used in a visualisation within a Qlik sheet, this can cause Incomplete Visualisation errors. This is because, technically speaking, the developer has specified a field that no longer exists for the user; it’s been removed from the users session/app.
Design tips for omitted fields
As Qlik developers we need to cater for this possibility when omitting fields. Outlined below is a non-exhaustive list of my top tips when it comes to visualising fields that may be omitted for a sub-group of users:
- Where possible limit the use of omitted fields to visualisations that support show/hide dimensions and measures, such as the Table and Pivot table objects. The granular control of individual dimensions and measures means you can still render the visual with the other, still present, dimensions/measures in the visualisation.
- Alternatively consider using calculation conditions on the entire visualisation, and create a version of the visual without the omitted field. You can then put both versions in the recently added native Qlik container with a conditional show/hide expression – this can control the most appropriate version to display to the user, and they’d be none-the-wiser.
- As a last resort, where the visualisation doesn’t contain show/hide controls, consider using conditional statements in the actual dimension (in the form of a calculated dimension) or expression. It should be noted that this may impact performance.
As you can see, these solutions all focus on utilising show/hide conditions. Let’s look at how these can be created.
Implementing calculated conditions
The solution I typically implement involves building a list of the omitted fields. This involves adding a table at the bottom of the section application script which will include importing the data powering the Section Access table again, but this time with just the USERID and a new field containing the omitted field names:
By including the USERID, it will relate back to the section access table and limit the data to just the user’s records. By including the OMIT field, we can use this in an expression for determining whether to show the field/visualisation or not. In my sample application, the above create created the highlighted data island:
You may wish to tidy this up by storing the results in a variable or hiding the fields from view in the front-end using hidePrefix or hideSuffix. I’ll leave that decision up to you. Let’s continue with implementing the conditional expression. Here is an example of what I used recently:
This reads, if the field ‘DIM2’ or ‘Dim2’ is not omitted evaluate to true and show the field, otherwise evaluate to false and hide it. In this example we are checking for the presence of the field DIM2 which we are reliant on, but there could be multiple fields in complex expressions. Therefore, you may need to extend this further. Having said that, this expression could be used in the conditional show/hide of a Dimension or Measure in certain visualisations or in the calculated condition of the entire visualisation. When editing a visualisation with a conditional calculation, the Dimension/Measure will produce this warning when the condition evaluates to false, in this case meaning the field is omitted:
Hopefully this gives you some insight into one approach to solving Incomplete visualisations when working with omitted fields in section access. If you have another or better solution to this issue please do share them with us.
By Chris Lofthouse #QlikLuminary