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: 
David_K
Creator
Creator

How can I include a Variable into a Set Analysis expression.

Hi Fellow Qlik Sense Users,

I have created a Set Analysis expression to fix a chart to show the current year data which works perfectly OK.

Count({<YEAR={'2023'},RETURNED={[NO]}>}AREA),

However what I would like to do is to replace the fixed year '2023' with a variable. 

The variable I have is:

=Year(Yearstart(Today()))  

This produces the result 2023 which is correct.

I'd like to be able to incorporate the Variable into the Set Analysis, which I have tried, but the output is blank.

Can anyone please guide me in the right direction.

Many thanks,

David

1 Solution

Accepted Solutions
MatheusC
Specialist III
Specialist III

Hi, @David_K 


put your variable like vYear = $(=Year(Today()))

then in the analysis set just insert it next to the $

Count({<YEAR={"$(vYear)"},RETURNED={[NO]}>}AREA),

or better if your database your year field has the maximum year until 2023

I would make the variable like below, making it more dynamic


vYear = $(=Max(fieldYear))

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!

View solution in original post

2 Replies
MatheusC
Specialist III
Specialist III

Hi, @David_K 


put your variable like vYear = $(=Year(Today()))

then in the analysis set just insert it next to the $

Count({<YEAR={"$(vYear)"},RETURNED={[NO]}>}AREA),

or better if your database your year field has the maximum year until 2023

I would make the variable like below, making it more dynamic


vYear = $(=Max(fieldYear))

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
David_K
Creator
Creator
Author

Hi MatheusC,

many thanks for the feedback, your solution has worked perfectly.