Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join “Do More With Qlik” with Mike Tarallo to get a first-hand look at the New Authoring Experience, June 29th: REGISTER HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Creating variables in the load script containing '='

Hello.

I have a large amount of variables I wish to define in the load script. I have done so like this

//Rank Retrieval

//Full Sales Force

SET vCalculateDayTakenRank=Only({$<SalesRep>}LineHistory_TakenRanking.DayTakenRank);

SET vCalculateWeekTakenRank=Only({$<SalesRep>}LineHistory_TakenRanking.WeekTakenRank);

SET vCalculateLastWeekTakenRank=Only({$<SalesRep>}LineHistory_TakenRanking.LastWeekTakenRank);

SET vCalculateMonthTakenRank=Only({$<SalesRep>}LineHistory_TakenRanking.MonthTakenRank);

followed by many more.

These variables work when added one by one in variable overview.

In the load script I cannot add the = required to initialise the code.


I have chosen to define them in my load script because of the large number and because I need to copy this structure into a number of other applications.

Things that I have tried so far:

SET vCalculateDayTakenRank==Only({$<SalesRep>}LineHistory_TakenRanking.DayTakenRank);

SET vCalculateDayTakenRank='=Only({$<SalesRep>}LineHistory_TakenRanking.DayTakenRank)';

SET vCalculateDayTakenRank=[=Only({$<SalesRep>}LineHistory_TakenRanking.DayTakenRank)];

SET vCalculateDayTakenRank="=Only({$<SalesRep>}LineHistory_TakenRanking.DayTakenRank)";

SET vCalculateDayTakenRank="'=Only({$<SalesRep>}LineHistory_TakenRanking.DayTakenRank)'";

1 Solution

Accepted Solutions
Henric_Cronström

Set should work just as well. Try

SET vCalculateDayTakenRank = =Only({$<SalesRep>}LineHistory_TakenRanking.DayTakenRank);

with a space between the two equals signs.

HIC

View solution in original post

9 Replies
petter
Partner
Partner

Try LET instead of SET when you use delimiters for the string.

Not applicable
Author

Does this force the variable to contain a static value upon reload?

I want to be able to calculate the result whenever I call the variable because SalesRep is not a static selection

rubenmarin

Hi Joshua, I used your double quotes option and seems worked:

From:

SET vCalculateDayTakenRank="=Only({$<SalesRep>}LineHistory_TakenRanking.DayTakenRank)";

Created this variable:

tresesco
MVP
MVP

Sum of your tried options should work. Like:

SET vCalculateDayTakenRank='=Only({$<SalesRep>}LineHistory_TakenRanking.DayTakenRank)';

seems to be fine. Try =vCalculateDayTakenRank in a text box. Doesn't it give your expected output? Could you post a sample qvw that shows the issue you are talking about?

Henric_Cronström

Set should work just as well. Try

SET vCalculateDayTakenRank = =Only({$<SalesRep>}LineHistory_TakenRanking.DayTakenRank);

with a space between the two equals signs.

HIC

jonathandienst
Partner
Partner

The Set works fine, I use it all the time, but you need a space between the two = sign.


SET vCalculateDayTakenRank= =Only({$<SalesRep>}LineHistory_TakenRanking.DayTakenRank);

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hey Ruben,

I tried your method and it did indeed work this time. Perhaps I had not tried double quotes properly.

Not applicable
Author

It was returning a null in my sample text box when an integer was expected.

I think I may have accidentally forgot to reset the SalesRep selection upon reload though

Not applicable
Author

Thanks henric, out of all of these I think this is the easiest option (I have a good few variables written already so this should be easy to do via find and replace)