Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Shahzad_Ahsan
Creator III
Creator III

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
Partner - Champion
Partner - Champion

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;

View solution in original post

7 Replies
petter
Partner - Champion III
Partner - Champion III

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

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
Creator III
Creator III
Author

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
Creator III
Creator III
Author

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

agigliotti
Partner - Champion
Partner - Champion

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

i hope it helps.

agigliotti
Partner - Champion
Partner - Champion

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
Creator III
Creator III
Author

This is what I needed.

Thanks Andrea