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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
t_hylander
Creator
Creator

Use variables in set analysis

Hi,

Ive got a couple of charts that uses the same selections in their set analysis and I thought Id use a variable instead so I can change them all from one place.

ex.

count({<customer={'1001','1002','1003'}, type -= {'10','20'} >} orders)

What Id like is to replace the whole line and in some cases add more selection so it might look something like this;

Count({<$(vCustomerTypeSelection), artnr={'2423','4222'} >} orders)

Is it possible, or do I have to settle with two variables contaning just the "numbers" (in the above case)?

Thanks in advance!

/Tomas

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

I think this should be possible:

Count({<$(vCustomerTypeSelection), artnr={'2423','4222'} >} orders)

The only issue would be the syntax editor won't understand the syntax, but that should not stop you from getting the same result as this

Count({<customer={'1001','1002','1003'}, artnr={'2423','4222'}>} orders)

View solution in original post

13 Replies
sunny_talwar
MVP
MVP

I think this should be possible:

Count({<$(vCustomerTypeSelection), artnr={'2423','4222'} >} orders)

The only issue would be the syntax editor won't understand the syntax, but that should not stop you from getting the same result as this

Count({<customer={'1001','1002','1003'}, artnr={'2423','4222'}>} orders)

trdandamudi
Master II
Master II

It is possible and I did used in various applications..

Count({<$(vCustomerTypeSelection), artnr={'2423','4222'} >} orders)

t_hylander
Creator
Creator
Author

I havnt used varables much, how would the set/let look like for it to work?

t_hylander
Creator
Creator
Author

Ive now also having trouble using dates...

In load-script I have this;

Let vCurrYear  = Year(now());
Let vCurrMonth  = month(now());
Let vCurrWeek  = week(now());
Let vCurrDay = date(now());

and in a simple text-object I tested with this;  (and a couple of other variants)

count({1<%Date={'${=$(vCurrDay)}'}>}Transnr)  

This just shows a '0' (where I know it should display '11')

Year, month and week works as they should, like this;

count({1<År={$(vCurrYear)}>}Transnr)

%Date is a key to a calendar and its content is like '2016-07-29' (the same as 'date(now())' is)

Ive also tried;

count({1<%Date={=date(now())} >}Transnr)

but it generates the error "Error in the set modifier ad hoc element list: ',' or ')' expected"

Any clues?

sunny_talwar
MVP
MVP

Would you be able to share a sample where you might be testing all this out?

jonathandienst
Partner - Champion III
Partner - Champion III

>>I havnt used varables much, how would the set/let look like for it to work?

Set vCustomerTypeSelection = customer={'1001','1002','1003'};

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
rubenmarin
MVP
MVP

Hi Tomas, about the dates...

count({1<%Date={'${=$(vCurrDay)}'}>}Transnr) --> try:

count({1<%Date={'$(vCurrDay)'}>}Transnr)


count({1<%Date={=date(now())} >}Transnr) --> try:

count({1<%Date={'$(=date(now()))'}>}Transnr)

t_hylander
Creator
Creator
Author

Tried but didnt work...

sunny_talwar
MVP
MVP

Seems to be working:

Capture.PNG