Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

New Contributor

Variables in set analysis

Hi all,

I´m making a new dashboard in Qlik.

My bussiness are related with incidences, so, count(NumberIncidences) will be usual to use...

Anyway, I´m trying to use variables in a simple set analysis.

Here my var:

nameVar: vCurrentMonth

expression of var: vCurrentMonth = Month(Today())

Y would like to know my incidences in a current month with set analysis, i would like to know this month, next month, etc.

I would like to have this information instanly, without filters applied. So:

Here my set analysis expression:


I´m totally deseperate, because I tested to get and represent the value of my variable typing the next:


and the result is 3. that´s perfect!, but when i try to put in a setAnalysis Expression...EXPLOIT! never work!

any help or manual or whatever will be very very helpful!

Thanks in advance

5 Replies

Re: Variables in set analysis

May be this

=Count({<MONTH = {"$(=$(vCurrentMonth))"}>} NumberIncidences)

New Contributor

Re: Variables in set analysis

Thank you for your answer, but it doesn´t work.

I´ve already tried it and still not working.

is there any document, procedure to type or debug setAnaysis expressions??

how is possible something that is really easy does no works ?


Re: Variables in set analysis

Try using double quotes in the set analysis for the variable. Additionally, if you're not evaluated your variable in the definition (LET/SET), you'll need to do it in the expression as well:

Try this:

=Count({<MONTH = {"=$(vCurrentMonth)"}>} NumberIncidences)

=Count({<MONTH = {"=$(=$(vCurrentMonth))"}>} NumberIncidences)

Re: Variables in set analysis

Set analysis get tricky with variables, you can check these threads to understand dates within set analysis better

Dates in Set Analysis

The Magic of Dollar Expansions

The Magic of Variables


Re: Variables in set analysis

Hi juancarlos.diago,

first of all, I believe Month(Today()) is returning you 'March' instead of '3'. You are probably visualizing the variable with 'number format'. That being said, see my below comments.

If you'd like to set a unique month to your expression, you can use single quote assignment in your set analysis.

If you'd like to set another relational operation to your expression (e.g., >=, <=, etc), you can use double quotes instead.

// In script

LET vCurrentMonth = Month(Today());         // March

LET vCurrentMonthNum = Num(Month(Today())); // 3

// In KPI

Count({<Month={'$(vCurrentMonthNum)'}>}NumberIncidences)       // Number of incidences in March - single quoted

Count({<Month={">=$(vCurrentMonthNum)"}>}NumberIncidences)  // Number of incidences in March or later - double quoted


Hope this helps


Edit: Did this solve the problem?

Community Browser