Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Folks,
I'm looking to evaluate an Only statement in the script. I have an example below.
[Test]:
Load * Inline
[
'Name', 'Food',
'Bob', 'Apple',
'Carl', 'Iberian Ham'
]
;
Set vBestFood = Only({<[Name]={'Bob'}>} Food)
;
Trace 'The best food here is $(vBestFood)'
;
Exit Script
;
I am trying to get the following output:
"The best food here is Apple"
Any help is greatly appreciated.
Hi Justin,
Unfortunately this can't be done as described - neither Only() nor Set Analysis can be used in the Script - these are both Chart functions/features.
In the script, you should think similarly to the SQL logic - load the desired data row with a WHERE condition, and then fetch the result into a variable using the Peek() function.
Join us at the Masters Summit for Qlik in Orlando or in Dublin to learn advanced Set Analysis, scripting, data modeling, performance, visualizations, and more - delivered by some of the best Qlik experts in the world!
Hi Justin,
Unfortunately this can't be done as described - neither Only() nor Set Analysis can be used in the Script - these are both Chart functions/features.
In the script, you should think similarly to the SQL logic - load the desired data row with a WHERE condition, and then fetch the result into a variable using the Peek() function.
Join us at the Masters Summit for Qlik in Orlando or in Dublin to learn advanced Set Analysis, scripting, data modeling, performance, visualizations, and more - delivered by some of the best Qlik experts in the world!
It's not possible to assign certain - aggregated and/or with any conditions - table/field-results to a variable. If you want to grab such values you will need a load-statement which fetched this data and then you could grab this value per peek() or fieldvalue().
In your probably simplified example you could get the wanted results per:
let vBestFood = fieldvalue('Food', fieldindex('Name', 'Bob')); trace $(vBestFood);
but with a bit more complex data it's rather unlikely that they are unique enough for such an approach.