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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
dana
Creator III
Creator III

Set Analysis expression in A variable

Hi,

I need to create a dynamic date range for set analysis

Sum({<$(vClearPeriods),Date_Num = {$(vCurrentPeriodSelected)}>}[Quantity KPI])

where vCurrentPeriodSelected is defined like that:

=If($(vDateButtonSelected)=1,
">=$(=Min(Date_Num))<=$(=Max(Date_Num))"
,
">=$(=Num(YearStart(Max(Date_Num))))<=$(=Max(Date_Num))"

Another words, I want final date string to be included in the expression.

Unfortunately, I receive an empty string:

dana_0-1733038601866.png

Help would be much appreciated...

 

Labels (3)
1 Solution

Accepted Solutions
nimishpgupta
Contributor II
Contributor II

Correcting some syntax error in above comment

Var1 =If('$(vDateButtonSelected)=1','$(varOption1)','$(varOption2)')

varOption1 ='">=$(=Min(Date_Num))<=$(=Max(Date_Num))"'

varOption2 ='">=$(=Num(YearStart(Max(Date_Num))))<=$(=Max(Date_Num))"'

 

 

Sum({<$(vClearPeriods),Date_Num = {$(Var1)}>}[Quantity KPI])

 

 

 

View solution in original post

3 Replies
nimishpgupta
Contributor II
Contributor II

You can create three variables like below

Var1 =If('$(vDateButtonSelected)=1',$(varOption1)','$(varOption2)

 

And then in your expression use $(var1) this

 

 

 

nimishpgupta
Contributor II
Contributor II

Correcting some syntax error in above comment

Var1 =If('$(vDateButtonSelected)=1','$(varOption1)','$(varOption2)')

varOption1 ='">=$(=Min(Date_Num))<=$(=Max(Date_Num))"'

varOption2 ='">=$(=Num(YearStart(Max(Date_Num))))<=$(=Max(Date_Num))"'

 

 

Sum({<$(vClearPeriods),Date_Num = {$(Var1)}>}[Quantity KPI])

 

 

 

dana
Creator III
Creator III
Author

Hi @nimishpgupta,

I updated the expression based on what you suggested, but without adding variables.

Just added the char as you did, and now it works!

=If('$(vDateButtonSelected)=1',
'">=$(=Min(Date_Num))<=$(=Max(Date_Num))"'
,
'">=$(=Num(YearStart(Max(Date_Num))))<=$(=Max(Date_Num))"'
)

Thanks for your help!