Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need some help with Only and set analysis

Hi,

I'm using a Only function with a set analysis in variable, it looks something like this:

=only({<UserCode={$(=UserName)}>} UserSiteCode)

Username is another variable with the following code: =mid(OSUser(),13)

I display the UserSiteCode in a Text Object on the main page.

Now here is problem - when I open the model the variable is null, but as soon as I go to another sheet and then back to the main then the variable contains the correct value. 

Why is it doing it?

1 Solution

Accepted Solutions
Not applicable
Author

I found the problem ....

The macro where I set my selection for site was on the Sheet open trigger.  When I ran the macro on the document open trigger as well all was 100% ....

Thanks all

View solution in original post

5 Replies
Anonymous
Not applicable
Author

Try defining your variable without the = at the beginning.  Your set analysis doesn't need the  = in the extension either and try using quotes too

=only ({<UserCode={'$(UserName)'}>} UserSiteCode)

Not applicable
Author

Nope ... still the same.  I think I must explain myself better.  The variable is working fine but the problem is the variable is not populated with a value on startup - I must switch between sheets before is it is populated with the site code.

don_qlikview
Creator
Creator

Can you try writing this in your script

Let UserName = mid(OSUser(),13);

and check in the variable overview if that variable is holding the value or not.

Not applicable
Author

OK,  I tried the following.

I entered this into my script:

Set UserName='=mid(OSUser(),13)';

Set Site='=only({<UserCode={"#(UserName)"}>} UserSiteCode)';

Let Site = replace('$(Site)', '#', chr(36));

But still the same.  As soon as I enter the model Username has it's value but Site Not?  When I click on the second sheet and then back to the main tab then Site has the correct value .....

Not applicable
Author

I found the problem ....

The macro where I set my selection for site was on the Sheet open trigger.  When I ran the macro on the document open trigger as well all was 100% ....

Thanks all