Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Hakan_Hansson
Contributor
Contributor

Create variable in script vs variable settings

I'm fond of the new syntax for set analysis and is experimenting to put set expressions into master items. At this point I also try to read these expressions from variables. I do see problems when creating such variable in script vs in variable area.

Example:

In script I create:

  • LET vMaxDateMonthEnd = '=MonthEnd(Date(Max(Datum)))';
  • SET vSA_MaxDateMonthEnd = {<Källa={'ANST_Månad'}>}{<Datum={">=$(vMaxDateMonthEnd)"}>};

After script load I have the following variable in variable area, see picture. I have no problem, though, to CREATE such variable in variable area (even if the syntax check complains) and use it accordingly in my application. 

So there is a solution but I do prefer creating variables in script for reuse and source control. Is there a script solution to make the variable to 'stay' as defined in the SET creation? I do have tried many different syntax alternatives but they all end up as:

  • {<Källa={'ANST_Månad'}>}{<Datum={">==MonthEnd(Date(Max(Datum)))"}>}

It is the expansion of $(vMaxDateMonthEnd) that ruins my day. 😎

 

 

Labels (2)
1 Solution

Accepted Solutions
RsQK
Creator II
Creator II

Hi, try it like this instead:

SET vMaxDateMonthEnd = '=MonthEnd(Date(Max(Datum)))';
LET vSA_MaxDateMonthEnd = REPLACE(REPLACE('{<Källa={‘ANST_Månad‘}>},{<Datum={">=#(vMaxDateMonthEnd)"}>}','‘',CHR(39)),'#','$');

View solution in original post

1 Reply
RsQK
Creator II
Creator II

Hi, try it like this instead:

SET vMaxDateMonthEnd = '=MonthEnd(Date(Max(Datum)))';
LET vSA_MaxDateMonthEnd = REPLACE(REPLACE('{<Källa={‘ANST_Månad‘}>},{<Datum={">=#(vMaxDateMonthEnd)"}>}','‘',CHR(39)),'#','$');