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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
jelindbe
Partner - Contributor III
Partner - Contributor III

Set analysis in script

I try to load a variable defined as:

Set vMyformula="Sum({<Year={$(=MAX({$<[Sales] -= {'=(NULL())'} >}Year))}>}[Sales])";

When I call this variable with $(vMyformula) in a table it returns  Sum({<Year={}>}[Sales]). The expected result would be Sum({<Year={2020}>}[Sales]).

If I copy and paste the formula itself  (Sum(....)) into the expression editor it works as expected.

I would appreciate any guidance. 

Labels (2)
1 Solution

Accepted Solutions
stevejoyce
Specialist II
Specialist II

the load script tries to evaluate the dollar sign expanded.  you can have placeholder characters and use replace, but it's cleaner and easier to manage use this nifty trick using mapping load + mapsubstring


mapping_specialchars:
mapping load * inline [
from, to
@, $
|, '
]
;

 

Let vMyformula=mapsubstring('mapping_specialchars', 'Sum({<Year={@(=MAX({$<[Sales] -= {|=(NULL())|} >}Year))}>}[Sales])');

View solution in original post

2 Replies
stevejoyce
Specialist II
Specialist II

the load script tries to evaluate the dollar sign expanded.  you can have placeholder characters and use replace, but it's cleaner and easier to manage use this nifty trick using mapping load + mapsubstring


mapping_specialchars:
mapping load * inline [
from, to
@, $
|, '
]
;

 

Let vMyformula=mapsubstring('mapping_specialchars', 'Sum({<Year={@(=MAX({$<[Sales] -= {|=(NULL())|} >}Year))}>}[Sales])');

jelindbe
Partner - Contributor III
Partner - Contributor III
Author

That one did the trick! Thank you!