Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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 Name | Role |
MV\SAM | SALESMAN |
MV\PAM | DEVELOPER |
MV\DAN | SUPERVISOR |
THanks,
ZAG
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.
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.
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?
Forget my response. Got it to work. Thanks so much!
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.
Lol! We're trading responses at the same time! Glad you got it working