Qlikview variable expression in Load Script

1.3k views Asked by At

I have a load script and I'm trying to do the following variable:

set vTest = if('$(dialMode)'='Month',sum(Comps.SpendDollers));

When I run this script and look in my "Variable Overview" I can see that it's coming out to:

if('Week'='Month',sum(Comps.SpendDollers))

Could someone explain to me how I get the variable "dialMode" to evaluate when I use the variable in my document, and not when the Load Script is ran?

I hope I've made myself clear, please let me know if not.

1

There are 1 answers

0
The Budac On

The dollar expansion is unnecessary, but you do need some inverted commas (") and an equals sign to make the script place the text into the variable as an expression not just a string.

set vTest = "=if(dialMode='Month',sum(Comps.SpendDollers))";

Surely the variable can be calculated outside of the vTest variable you only need the value of the expression not the expression. What I did even handled spaces in dialMode.

set vTest2 = "=if(dialMode='Month 5',sum(Comps.SpendDollers))";

set dialMode="=concat(distinct [Dial])";

load * inline [
Comps.SpendDollers, Dial
1,Month 5
2,Week
3,Day
];