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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
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

13 Replies
rubenmarin

Hi Tomas, your date field is called transdate, set analysis is asigned to a field.

Also the number field is transnr (all lowercase), try with:

=count({1<transdate={'$(vCurrDay)'}>}transnr) & chr(13) &

count({1<transdate={'$(=date(now()))'}>}transnr)

Edit: As Sunny posted above, if you only want the date, is better to use Today() instead of Now().

t_hylander
Creator
Creator
Author

sorry, I was inconsistent with names and sloppy when I made the exemple...in the exemple it works yes.

But...

Thanks to you I got this to work;

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

but this doesnt;

Count({1<%Date = {"$(=Date(Today()))"}>} Transnr)

If I use

Let vCurrDay = date(now());

and then

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

it all works now but not with "let vCurrDay = today()" or "date(today())"

rubenmarin

Hi Tomas, Now() and Today() can have a parameter wich tells the date to return based on:

0 - Script execution

1 - Function call

2 - Document opened

Default for Today() is '2', default for Now() is '1', the thing with option '1' is that system clock changes so often that it can cause an impact on performance, but this is when expression are related between them, usually it works fine.

You can also test in a text box if there is a difference, create a text box with =Date(Now()) and another with =Date(Today()).

I get the same result with both so I don't know why Today() isn't working for you, maybe a typo? Anyway, if Now() gives a good performance keep them.

t_hylander
Creator
Creator
Author

Its a small app so performance isnt a issue. I'll go with now() for now

Thanks!