Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Show data in a column based on User ID

In my application, I have a straight table that has a column called "Client Name".  I want to have what is displayed in this field to be based on the user.  If a users belongs to an "Administrator" group, I want the data as shown in the model to display.  Otherwise, I want to display a dash.  I have loaded a table into the model with the Users (which would match the results of OSUser() ) and a flag field for Admin/Not Admin.  I just cannot determine the correct formula to use to make the connection... something like an Excel VLookup().  Any ideas?

1 Solution

Accepted Solutions
Not applicable
Author

I was actually able to solve my problem using set analysis.  My resulting expression looks like this:

=if(Sum({$<SecNTName_UC={$(=UPPER(OSUser()))}>}SecShowClient) = 1, ClientName, if(Sum({$<SecNTName_UC={$(=UPPER(OSUser()))}>} SecBranchID)= BranchID, ClientName,'-'))

The fields in the User table look like this:

SecNTName_UCSecShowClientSecBranchID
DOMAIN\USER110
DOMAIN\USER210
DOMAIN\USER301234
DOMAIN\USER402345

The nested IF is saying if the sum of the "SecShowClient" field (limited by the OSUser() ) is 1 then show the ClientName; otherwise only show the ClientName field when the "SecBranchID" matches the one assigned to the OSUser()

View solution in original post

6 Replies
Colin-Albert

A more secure option would be to look at Section Access with Data Reduction, as this will remove data that the user is not permitted to view rather than just hiding it.

Have a look here for more details on Section Access.  Introduction to Section Access

shree909
Partner - Specialist II
Partner - Specialist II

it would be good, if you can share an sample app and what output your expecting?

Not applicable
Author

Thanks Colin.  In this case we don't want to reduce the data.  We still want all users to see components of the data, but one particular field we want to suppress the details.

Not applicable
Author

I was actually able to solve my problem using set analysis.  My resulting expression looks like this:

=if(Sum({$<SecNTName_UC={$(=UPPER(OSUser()))}>}SecShowClient) = 1, ClientName, if(Sum({$<SecNTName_UC={$(=UPPER(OSUser()))}>} SecBranchID)= BranchID, ClientName,'-'))

The fields in the User table look like this:

SecNTName_UCSecShowClientSecBranchID
DOMAIN\USER110
DOMAIN\USER210
DOMAIN\USER301234
DOMAIN\USER402345

The nested IF is saying if the sum of the "SecShowClient" field (limited by the OSUser() ) is 1 then show the ClientName; otherwise only show the ClientName field when the "SecBranchID" matches the one assigned to the OSUser()

QlikQlaker
Contributor III
Contributor III

Hey, this is amazing, but I am having a rough time here... I'm trying to do something very similar to what you wanted except i have a table of users that have access.  I'm trying to set it so that they have access to what they need without access to what they can't have.  We've got the qlik usernames stored in a table, so i just need to compare the username in the table with the username logged in to the access level.  

my fields are qlikuser (from the db), subfield(osuser(),'=',-1) (logged in user), and planid

 

my current analysis is:  =if(count({Qlikuser={$(upper(subfield(osuser(),'=',-1)))}>}PlanID)>0,PlanID)

example data would be

table:

user1     planA

user1     planB

user2     planB

 

user1 logon:

data data data planA

data data data planB

 

user2 logon

data data data 

data data data planB

 

Do you think this would conform?

Thanks ❤️ 

QlikQlaker
Contributor III
Contributor III

ok, for anyone else, this is the current addition to this other person's wonderful start:

 

=if(count({$<QlikUser={$(=upper(subfield(osuser(),'=',-1)))}>}PlanID)>0, PlanID, NULL())

 

I think this is going to work for what i need!  - will let you know!