Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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 ??
Id | Name | Inserted_By |
---|---|---|
1 | A | User1 |
2 | B | User2 |
3 | C | User2 |
4 | D | User1 |
5 | E | User1 |
6 | F | User1 |
7 | G | User2 |
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;
Section Access is the way to go to cover your requirements:
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.
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
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];
Here is sample excel data. I need to restrict 'user1' to see only 2017 data
i suggest you to take a look at working with SA in Qliksense qmc
i hope it helps.
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;
This is what I needed.
Thanks Andrea