Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
bwisealiahmad
Partner - Specialist
Partner - Specialist

What dos {$1} in the modifier do in Set Analysis

This might be a really simple question, but I am hoping someone can point me in the way of some good documentation on this.

I've seen examples where {$1} is used in the moderator. What exactly does this mean?

Example could be

Sum({<Account = {$1}, Company = {$2}>}Sales)

Thanks.

27 Replies
sunny_talwar

I am not an expert on performance, but from what I see it only seems to be something which might be helpful if you have multiple expressions in different places which are similar but not the same. Not entirely sure if there is any performance benefit.... but petter-s‌, johnw‌‌, swuehl‌ or some other expert might be able to guide you better here.

Another way would be to test it for yourself by creating two objects on two tabs and testing there performance. Test one object at a time and note there time in sheet properties window 3 times. Each time close the app to make sure you take caching out of the equation.

Best,

Sunny

bwisealiahmad
Partner - Specialist
Partner - Specialist
Author

Ok. I think I understand.

So if it says Account = {$1} is this "1" the first on a list where this is getting it from? Where do I define that what $1 is?

bwisealiahmad
Partner - Specialist
Partner - Specialist
Author

Nevermind. I got it.


The set analysis is set in the variabel and the $1, $2 etc defined in the set analysus. is where the parameters defined in the variable goes .Pling (lightbulb turned on sound)

sunny_talwar

Yes, you are right, while using the variable... you just give the parameters.

$(vVar(Parameter1, Parameter2))

bwisealiahmad
Partner - Specialist
Partner - Specialist
Author

Any good books or courses you can recommend Sunny?  Seems like you're quite good at scripting.

sunny_talwar

I have learned all that I know from this community and trying out things on my own. I am very curious about how we can solve a single problem in many different ways. You would see that my solutions are not always the best performing ones and that is because I am still learning from the real gurus.

So my friend, I am not the best person to advice you on this may be someone else can pitch it here

Best,

Sunny

johnw
Champion III
Champion III

My guess is that there would be no discernable memory or performance difference between using a variable version of an expression and a raw expression. You might think something like "if I use the variable in more than one place, then it only has to calculate it once!" That may be true but I suspect that in any case you could come up with where that was true, writing the whole expression out would also, due to QlikView's caching, result in it only being calculated once.

But with any performance question, the real answer is to try it both ways in your actual application and see if there's any difference. All the theorizing in the world means nothing compared to just trying it out, and I am certainly not always right in my guesses! QlikView still surprises me sometimes.

I mostly use variables so that I'm not repeating expressions, not for performance.

I've run into problems when variables try to use results from other variables, though, so I avoid that. I believe QlikView likes to calculate everything that it can in parallel, so it can end up calculating out of the desired order. It might have been nice for QlikView to figure out in what order to perform calculations. That gets pretty complex, though, and I've had to code exactly that before. But if I can do it, so can the people at Qlik. (Though my method was inefficient performance-wise, and depended on an uncalculated variable being null, not having some previous value in it still. I'm sure they could do better.)

Medea93
Contributor II
Contributor II

$ represents the current selection state. Adding 1 to it (making it $1) refers to the alternative selection state. This means the expression will consider the data in the context of the first alternative state defined in your app.