Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I have an issue with the creation of a variable in the script part, however it seems to be problematic, hope somebody can have a quick look
This is my data
t1
Id | Dim | Val |
id1 | a | 5 |
id1 | b | 7 |
id1 | c | 19 |
id2 | a | 8 |
id2 | b | 10 |
id2 | c | 15 |
Another field called "DimSelect" used in the set analysis later and refered to by the GetFieldSelections expression is created by ->
Nav:
Load Distinct
Dim as DimSelect
Resident t1;
Now, creating chart function works fine:
=aggr(max( {<Dim={'$(=GetfFeldSelections(DimSelect))'}>} Val), Id)
However, I would like to have this chart function as a variable created in the script, and unfortunately it does not work
Script:
let vAggr = 'aggr(max( { <Dim = {"$(=GetFieldSelections(DimSelect))" }> } Val), Id)';
Chart:
=$(vAggr)
Does anyone possibly know what I am doing wrong? The issue seems to be with the expression GetfieldSelections(DimSelect), because inserting a value like "b" instead of GetFieldSelections expression also works fine.
Thanks!
let's try as below:
let vAggr = 'aggr(max( { <Dim = {"' & chr(36) & '(=GetFieldSelections(DimSelect))" } > } Val), Id)';
Please try change set instead let
Set vAggr = 'aggr(max( { <Dim = {"$(=GetFieldSelections(DimSelect))" }> } Val), Id)';
Hi Sunil, thanks for your quick reply. No, unfortunately it does not work, but inserting "b" instead of $(=GetFieldSelections(DimSelect)) works also with Set instead of Let and gives me results.
Or do I need to change something in the chart function as well?
Try to create variable in variable overview instead of script.
it may works
Hi Arvind, yes it works when I create this variable
formula -> aggr(max( {<Dim={'$(=GetFieldSelections(DimSelect))'}>} Val), Id)
in the variables part of the "front end", thanks for the tip. However, ideally and especially for upcoming maintenance, I would need it in the script load.
let's try as below:
let vAggr = 'aggr(max( { <Dim = {"' & chr(36) & '(=GetFieldSelections(DimSelect))" } > } Val), Id)';
Hi Fels,
Aggr is a front end function it cannot be used in script level.
One question pinching me,
Do you want the function to be executed in the backend ? or just want to create a variable with the definition using Aggr?
Looking to load formula then check this
Qlikview utilizando Expressão com origem no Excel
http://www.qlikfix.com/2011/09/21/storing-variables-outside-of-qlikview/
IMO is the creation of expression-variables within the script often not very beneficial because the used $-sign need a special treatment and also the various quotes and brackets need more attention as using an expression directly within an object. Should there be really multiple (between different applications) re-usable variables it would be better to store them externally as file and loading them as table and creating then the variables within a loop. Within this posting you will find various examples how such logic could be implemented (and many more to): Variables
Beside this you could use in your case a different set analysis approach to get the same result:
set vAggr = aggr(max({ <Dim = p(DimSelect)> } Val), Id);
- Marcus
Hi Andrea, thanks alot, that worked!