Qlik Community

Qlik Sense Advanced Authoring

Discussion board where members can learn more about Qlik Sense Advanced Authoring.

Announcements
BARC’s The BI Survey 19 makes it official. BI users love Qlik. GET REPORT
Highlighted
MikeH1983
New Contributor III

Section Access: Automatically set Restriction based on Department associated with User

Hi all. I'm not sure if this is possible, but if so could someone offer some guidance about how I can build it?

I want to build Section Access such that, for access type USER, QlikSense associates the User to their own Department, and then restricts the data to only show their Department. The aim is to not have to declare explicitly which Department each User should see, instead to have a rule that automates so that any User logged in can only see their Department.

I can identify the correct Department through an expression that connects the Username via OSUser() to their Department. So essentially I want QlikSense to take the result of this expression and apply security based on it.

For added complication, I would like to have access type ADMIN allowing a view of unrestricted data as well.

Any suggestions?

1 Solution

Accepted Solutions
MikeH1983
New Contributor III

Re: Section Access: Automatically set Restriction based on Department associated with User

I ended up finding a way to do this in the front end, with the departments associated with each userID captured in a table. Since I am not using Section Access this means that I am not filtering out all of the unwanted data, so I can still do cross-department comparisons etc.

In the script I created a table of NetIDs connected to User Personnel Numbers, with a lookup to a temporary Current Positions table to find the user's current Department. So now Qlik associates the Department on the NetworkIDs table with the Department of a Position, and I can use this to filter expressions in the front end. 

 

In the front end, I capture the part of the userID after the = sign in a variable: vUserNetID=upper(mid(osuser(),Index(osuser(), '=', 2)+1)). Now for all expressions for which I want data filtered only to include the users department, I start with =if(NetID=vUserNetID ... 

Its a bit slow but it works.

View solution in original post

2 Replies
qliksus
Valued Contributor II

Re: Section Access: Automatically set Restriction based on Department associated with User

Move the query to find the department for a particular user to backend and link it back to section acesss . something like the below

LOAD * INLINE [

UID , PWD, NTNAME, ACESSSTYPE,DEPARTMENT
A,A,*,USER,A
B,B,*,USER,B
]
Write the query to create a table structure like the below
DEPARTMENT:
LOAD * INLINE [

DEPARTMENT , DEPARTMENT_ACTUAL
A, HR
B,FINANCE
] ;

 

MikeH1983
New Contributor III

Re: Section Access: Automatically set Restriction based on Department associated with User

I ended up finding a way to do this in the front end, with the departments associated with each userID captured in a table. Since I am not using Section Access this means that I am not filtering out all of the unwanted data, so I can still do cross-department comparisons etc.

In the script I created a table of NetIDs connected to User Personnel Numbers, with a lookup to a temporary Current Positions table to find the user's current Department. So now Qlik associates the Department on the NetworkIDs table with the Department of a Position, and I can use this to filter expressions in the front end. 

 

In the front end, I capture the part of the userID after the = sign in a variable: vUserNetID=upper(mid(osuser(),Index(osuser(), '=', 2)+1)). Now for all expressions for which I want data filtered only to include the users department, I start with =if(NetID=vUserNetID ... 

Its a bit slow but it works.

View solution in original post