Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
krissy_s
Contributor III
Contributor III

Creating a variable in set analysis

Hiya

I have the following set expression (in a table):

=Aggr (Only({<[Expiry Date] = {">=$(=monthstart(Today()))<=$(=monthend(addmonths(today(),12)))"}>} [Expiry Date]),[Policy Number])

I need to create a variable in this set expression above:

 [Expiry Date] = {"$(=vExpiryRange)

Does anyone know to add this in please?

Many thanks

4 Replies
paoloderegibus
Partner - Contributor III
Partner - Contributor III

Hi Kristen,

 

you could try this:

in the script create this variable:

LET vExpiryRange = replace('"'&'>=@(=monthstart(Today()))<=@(=monthend(addmonths(today(),12)))'&'"','@','$');

and in charts use this dimesnion:

=Aggr(Only({<[Expiry Date] = {$(vExpiryRange)}>} [Expiry Date]),[Policy Number])

See the attached qvf.

Ciao

Paolo

krissy_s
Contributor III
Contributor III
Author

thank you so much! Will give it a go!

krissy_s
Contributor III
Contributor III
Author

Sorry, is it possible to write in the expression without having to edit the script?

Many thanks!

 

paoloderegibus
Partner - Contributor III
Partner - Contributor III

Sure, just create the variable and paste this in its expression: '"'&'>=$(=monthstart(Today()))<=$(=monthend(addmonths(today(),12)))'&'"'.