Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
curiousfellow
Specialist
Specialist

how to use osuser() in this expression

In this expression

If(DIMENSIONALITY()=2,SUM({<STATE_ID *= p(USER_STATE_ID) >}POPULATION),SUM(POPULATION))

I would like to replace  p(USER_STATE_ID) with something like p(osuser()) or a variable representing the user name, but I cannot find the correct syntax. Is it possible ?

 

 

 

 

Labels (1)
7 Replies
avinashelite

Create a variable like this 

vOSUser = OSUser()

Note: Osuser will the system login name 

curiousfellow
Specialist
Specialist
Author

I did try it with a variable, but when I replace  p(USER_STATE_ID) with p($(var_username) ,

so the expression will be If(DIMENSIONALITY()=2,SUM({<STATE_ID *= p($(var_username)) >}POPULATION),SUM(POPULATION)) it doesn't work .

>}POPULATION gets underlined red.

marcus_sommer

You could not use osuser() within p() but you could apply it in this way:

If(DIMENSIONALITY()=2,SUM({<STATE_ID *= {'$(=osuser())'} >}POPULATION),SUM(POPULATION))

whereby I assume it won't return your wanted results ... If not you should elaborate a bit more what fields contain which data and what do you want to achieve.

- Marcus

 

curiousfellow
Specialist
Specialist
Author

I am trying to restrict access to detailed information, but allow access to aggregated values. 

Something similar to the solution Swuehl made here :

https://community.qlik.com/t5/QlikView-Scripting/How-to-apply-Section-Access-to-reduce-part-of-the-d...

Brett_Bleess
Former Employee
Former Employee

Best I have that may be of some help is the following Design Blog post:

https://community.qlik.com/t5/Qlik-Design-Blog/Data-Reduction-Using-Multiple-Fields/ba-p/1474917

@swuehl any chance you have a little time to swing by and take a look at this post given reference to one of your prior ones to see if you can shed any further light upon things for the poster?  Thanks in advance if you can.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
swuehl
MVP
MVP

Sure, Brett.

@curiousfellow, could you describe your data model a bit more detailed? In the post you referenced above, the OP posted three simple tables as INLINE tables, to demonstrate his data model. Something like this adapted to your setting will help us better to help you.

curiousfellow
Specialist
Specialist
Author

My data model does not differ from the datamodel in your example  (Qlik example SA_2.qvw). The only difference is that all the data from   States and Population are in the same table.

In the meanwhile I managed to solve it for me. Referring to your example I linked te fields USER_STATE_ID and STATE_ID.  Username represents the osuser() name.

I added a calculated  dimension to my chart : if(USERNAME=var_OSUSER,STATENAME,'-'), works for me so far, only when details are presented, the totalvalue is presented too.

 

var_USER = osuser()