Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

$ expansion not working on a Variable in the Load script

Good Morning!

I have a bunch of variables that I have moved from the variable overview screen (where I initially created them) to the Script. I was thinking this would allow for easier maintenance.

The variables however so not work once in the script.

The variable in the Variable overview screen is: sum({<Year = {$(=Only(Year)-1)}>}LineSalesAmount)

In the script it's: set vTemp = sum({<Year = {$(=Only(Year))}>}LineSalesAmount);

The result when in variable overview is correct, gives you last year's sum.

The result when in the script is wrong! for some reason it puts in a blank (like it never saw the $ expansion) in the year dimension (I found this by  looking at the variable overview screen).

So when placed in the script QV thinks the variable is: sum({<Year = {}>}LineSalesAmount)

so apparently it's ignoring the $ expansion

Mystery? am I doing something wrong?

1 Solution

Accepted Solutions
Not applicable
Author

nope, didn't work

I think i'll just out the variables back into the variable overview screen and call it a day

View solution in original post

9 Replies
MK_QSL
MVP
MVP

In script, you can't use Set Analysis...

This is not allowed...

{<Year = {$(=Only(Year))}>}

Not applicable
Author

Hi,

Try that, it will make the function to be calculated in each selection (you dont need to use the expansion $ symbol):

set vTemp = = sum({<Year = {$(=Only(Year))}>}LineSalesAmount);

Not applicable
Author

This seemed to work, but I can't tell why the numbers aren't adding up. The formula says it's previous year, but the actual value is this year (or ignoring the set analysis).

Check attached sample

Anonymous
Not applicable
Author

hi,

use

let vTemp = '=sum({<Year = {"'  & chr(36) & '(=Only(Year)-1)"}>}Sales)';

in script. Problem here is that qlikview tries to evaluate the code after the $. Therefore replace it with it's ascii code.

Best

Stefan

Not applicable
Author

nope, didn't work

I think i'll just out the variables back into the variable overview screen and call it a day

vgutkovsky
Master II
Master II

But if you do that, QlikView wins, and we can't allow that Try this:

LET vTemp = 'sum({<Year={$';

LET vTemp = vTemp & '(=Only(Year))}>}LineSalesAmount)';

Vlad

Anonymous
Not applicable
Author

it does?!

maxgro
MVP
MVP

what about?

let vTemp2 = replace ('sum({<Year = {@(=Only(Year))}>} Sales)', '@', '$');

Not applicable
Author

I must've had a typo. Looks like it works!