Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Shahzad_Ahsan
Contributor II

How to restrict userwise data

Hi

I need to restrict data by user login. Suppose, If 'User1' has login, he should view only his data.

For example , look at the table. If User1 has login then he should view only 4 rows , that means Id 1,4,5,6 only.

How is this possible ??

IdNameInserted_By
1AUser1
2BUser2
3CUser2
4DUser1
5EUser1
6FUser1
7GUser2
1 Solution

Accepted Solutions
agigliotti
Honored Contributor II

Re: How to restrict userwise data

anyway you should do something as below:


[Sheet2]:

LOAD

    User,

    Id,

    Sales,

    Year

FROM [lib://Path/Section_Access.xlsx]

(ooxml, embedded labels, table is Sheet2);

SECTION ACCESS;

[TEST]:

LOAD *

INLINE [

ACCESS, USERID,USER, SA_YEAR

ADMIN, domain\admin, ALLVALUES

USER, domain\user1, user1, 2017

];

SECTION APPLICATION;

STAR IS '|*|';

Table_1:

Load [User] ,

  Upper([User]) AS USER

Resident [Sheet2];

Table_2:

Load

  SA_YEAR as Year,

  SA_YEAR

Resident TEST where SA_YEAR <> 'ALLVALUES';

concatenate

Load

    '|*|' as Year

    SA_YEAR

Resident TEST where SA_YEAR = 'ALLVALUES';


STAR IS;

7 Replies
MVP
MVP

Re: How to restrict userwise data

Section Access is the way to go to cover your requirements:

     https://help.qlik.com/en-US/sense/June2018/Subsystems/PlanningQlikSenseDeployments/Content/Deploymen...

Here is a good reference document with pointers to various resources about Section Access:

     https://community.qlik.com/docs/DOC-9039

Documention about section access for QlikView is also relevant for Qlik Sense as this is identical between the products.

balabhaskarqlik
Honored Contributor

Re: How to restrict userwise data

Try like this: Added for Hierarchy wise reduction, from this try for User wise.

LET vHierarchyDef='Country,State,City';

LET vLevels=Len(KeepChar(vHierarchyDef,',')) + 1;

Section Access;

LOAD * INLINE [

   ACCESS, USERID, REDUCTION

   ADMIN, US\SATISHKURRA,

   USER, US\SALIDINA, ILLINOIS

   USER, US\SREEDENON, TEXAS

   USER, SK, CHICAGO

];

Section Application;

For vAncLevels= 1 to vLevels

LET vAnc=SubField(vHierarchyDef,',',vAncLevels);

Trees:

LOAD Distinct

UPPER([$(vAnc)]) as REDUCTION,

[EmployeeGroup]

Resident Link;

   

Next vAncLevels

Shahzad_Ahsan
Contributor II

Re: How to restrict userwise data

Hi

After lots of analysis on Section Access, Finally I managed to restrict data userwise,

Now I want to make as yearwise also. Here is my script and its working fine for userwise restriction.

How we can manage Year also

[Sheet2]:

LOAD

    User,

    Id,

    Sales,

    Year

FROM [lib://Path/Section_Access.xlsx]

(ooxml, embedded labels, table is Sheet2);

SECTION ACCESS;

[TEST]:

LOAD *

INLINE [

ACCESS, USERID,USER

ADMIN, domain\admin,

USER, domain\user1, user1

];

SECTION APPLICATION;

Table_includes_Year_field:

Load [User] ,

  Upper([User]) AS USER

Resident [Sheet2];

Shahzad_Ahsan
Contributor II

Re: How to restrict userwise data

Here is sample excel data. I need to restrict 'user1' to see only 2017 data

agigliotti
Honored Contributor II

Re: How to restrict userwise data

i suggest you to take a look at working with SA in Qliksense qmc

i hope it helps.

agigliotti
Honored Contributor II

Re: How to restrict userwise data

anyway you should do something as below:


[Sheet2]:

LOAD

    User,

    Id,

    Sales,

    Year

FROM [lib://Path/Section_Access.xlsx]

(ooxml, embedded labels, table is Sheet2);

SECTION ACCESS;

[TEST]:

LOAD *

INLINE [

ACCESS, USERID,USER, SA_YEAR

ADMIN, domain\admin, ALLVALUES

USER, domain\user1, user1, 2017

];

SECTION APPLICATION;

STAR IS '|*|';

Table_1:

Load [User] ,

  Upper([User]) AS USER

Resident [Sheet2];

Table_2:

Load

  SA_YEAR as Year,

  SA_YEAR

Resident TEST where SA_YEAR <> 'ALLVALUES';

concatenate

Load

    '|*|' as Year

    SA_YEAR

Resident TEST where SA_YEAR = 'ALLVALUES';


STAR IS;

Shahzad_Ahsan
Contributor II

Re: How to restrict userwise data

This is what I needed.

Thanks Andrea