Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

anguila
Contributor

Store set analysis expression in the script

Hi,

I want to store and if statement expresion (containing set analysis) into a variable in the script for the future usage in expressions in some charts.

As the expression is the same in many charts is better having the same expresion in a variable for its future modifications.

I already defined that variable in the trigger section when the script finishes its reload. But for some reasons (developement flexibility, user scalability, all params together, etc..) I have to move into the script.

So my question exactly is: "How can I set a variable with this expresion in the script?":

     =if(Customer='Custom1',Only({1<IdField={TYPE1'}>} Method), Only({1<IdField={'TYPE2'}>} Method))

I tried let with no luck..

Thanks!

David.

1 Solution

Accepted Solutions
anguila
Contributor

Re: Store set analysis expression in the script

I solved it!

The problem was so silly.. the issue was with the single quotes of the set analysis, so I just surrounded it the expression with double quotes and it worked like a charm:

SET vExpre = "if(Customer='Custom1',Only({1<IdField={TYPE1'}>} Method), Only({1<IdField={'TYPE2'}>} Method))";

David.

5 Replies
daveamz01
Contributor III

Re: Store set analysis expression in the script

Hi David,

     Try SET vExpre = 'if(Customer='Custom1',Only({1<IdField={TYPE1'}>} Method), Only({1<IdField={'TYPE2'}>} Method))';

     or

     SET vExpre = '=if(Customer='Custom1',Only({1<IdField={TYPE1'}>} Method), Only({1<IdField={'TYPE2'}>} Method))';

     I tried the first variant and it works for a simple expression as field1+field2

Regards,

David

anguila
Contributor

Re: Store set analysis expression in the script

It doesn't work at all..

If I set the expression of a text object as: =vExpre the result is 'if(Customer='Custom1',Only({1<IdField={TYPE1'}>} Method), Only({1<IdField={'TYPE2'}>} Method))'

And when I try to access the value (expresion: =$(vExpre) the result is -

When I added this expression as a trigger or even as a variable, and I set the expresion of the text object as =vExpre, the result is the expresion WITHOUT quotes: if(Customer='Custom1',Only({1<IdField={TYPE1'}>} Method), Only({1<IdField={'TYPE2'}>} Method))

Any idea? I tried the both ways you said (with and without the equal).

Thanks for the reply!

anguila
Contributor

Re: Store set analysis expression in the script

I solved it!

The problem was so silly.. the issue was with the single quotes of the set analysis, so I just surrounded it the expression with double quotes and it worked like a charm:

SET vExpre = "if(Customer='Custom1',Only({1<IdField={TYPE1'}>} Method), Only({1<IdField={'TYPE2'}>} Method))";

David.

marcelo_7
Contributor

Re: Store set analysis expression in the script

I have a similar problem only that my expression uses both ' and ", any ideas?

num((1 - (sum({<DATUM={">=$(v7daysBack)<=$(v1dayBack)"}>}_Brist) / (sum({<DATUM={">=$(v7daysBack)<=$(v1dayBack)"}>}_Brist)+sum({<DATUM={">=$(v7daysBack)<=$(v1dayBack)"}>}_EJ_Brist))))*100,'##,0', ',')

anguila
Contributor

Re: Store set analysis expression in the script

try to replace the double quotes inside your expresion with chr(34), the same value in the ascii table.

Community Browser