Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

cancel
Showing results for 
Search instead for 
Did you mean: 
zagzebski
Creator
Creator

Matching OSUSER() with NT Name

I am trying to return the Role of a user in a text box based on matching NT Name and the OSUSER() Function.  So in the example below if SAM was the user the role returned would be:   SALESMAN

I tried something like this but can't get it to work yet:

aggr(only({<[User NT Name]={ '$(=OSUser())' >} [User Role]),[User NT Name] )

DATA:

User NT NameRole
MV\SAMSALESMAN
MV\PAMDEVELOPER
MV\DANSUPERVISOR

THanks,

ZAG

1 Solution

Accepted Solutions
evan_kurowski
Specialist
Specialist

Hello Zagzebski,

If you're running this function in a text box, try removing the Aggr() portion:

  only({<[User NT Name]={ '$(=Upper(OSUser()))'}>} [User Role])

*note: your original syntax is missing one curly brace

Since OSUser() can only return a single result for the current user, there's no point in aggregating over the entire user list anyway, you only want to match on OSUser(), and you shouldn't have an Aggr() as the outermost function in a text box because Aggr() is designed to return arrays, while a text box is designed for single result.

Also, I wrapped OSUser() within the set-analysis with an UPPER(), because case sensitivity that isn't aligned will cause a mis-hit.

View solution in original post

5 Replies
evan_kurowski
Specialist
Specialist

Hello Zagzebski,

If you're running this function in a text box, try removing the Aggr() portion:

  only({<[User NT Name]={ '$(=Upper(OSUser()))'}>} [User Role])

*note: your original syntax is missing one curly brace

Since OSUser() can only return a single result for the current user, there's no point in aggregating over the entire user list anyway, you only want to match on OSUser(), and you shouldn't have an Aggr() as the outermost function in a text box because Aggr() is designed to return arrays, while a text box is designed for single result.

Also, I wrapped OSUser() within the set-analysis with an UPPER(), because case sensitivity that isn't aligned will cause a mis-hit.

zagzebski
Creator
Creator
Author

Thanks Evan. I also tried that earlier but I keep getting the message:

Error in set modifier ad hoc element list: ',' or ')' expected

Any thoughts?

zagzebski
Creator
Creator
Author

Forget my response. Got it to work. Thanks so much!

evan_kurowski
Specialist
Specialist

Try this again...

only({<[User NT Name]={ '$(=Upper(OSUser()))'}>} [User Role])

I cut & pasted your original syntax and didn't notice your missing curly brace right away.  I have this expression working in my test app here.

evan_kurowski
Specialist
Specialist

Lol!  We're trading responses at the same time!  Glad you got it working